codecademy 命令行手册

BACKGROUND
The command line is a text interface for your computer. It’s a program that takes in commands, which it passes on to the computer’s operating system to run.
命令行是计算机上的文字用户交互界面,是一个接受命令并交给计算机操作系统执行的程序。

From the command line, you can navigate through files and folders on your computer, just as you would with Windows Explorer on Windows or Finder on Mac OS. The difference is that the command line is fully text-based.
从命令行,你可以浏览计算机上的文件和文件夹,就像window上的文件资源管理器或MacOS上的finder。不同的是命令行是完全基于文字(相对于图形界面)。

Here’s an appendix of commonly used commands.
下面的附录是一些常用的命令。


COMMANDS
>

$ cat oceans.txt > continents.txt

> takes the standard output of the command on the left, and redirects it to the file on the right.
接收左边命令的标准输出,转发到右边的文件。


>>

$ cat glaciers.txt >> rivers.txt

>>takes the standard output of the command on the left and appends (adds) it to the file on the right.
接收左边命令的标准输出,添加(追加)到右边的文件。


<

$ cat < lakes.txt

< takes the standard input from the file on the right and inputs it into the program on the left.
接收右边命令的标准输出,输出到左边的程序。


|

$ cat volcanoes.txt | wc

| is a “pipe”. The | takes the standard output of the command on the left, and pipes it as standard input to the command on the right. You can think of this as “command to command” redirection.
是一个“管道”。|接收左边命令的标准输出,作为右边命令的标准输入,你可以认为这是“命令到命令”的重定向。


~/.BASH_PROFILE

$ nano ~/.bash_profile

~/.bash_profile is the name of file used to store environment settings. It is commonly called the “bash profile”. When a session starts, it will load the contents of the bash profile before executing commands.
是保存环境设置的文件。通常被叫做“bash profile”。当一个会话启动,将在执行命令之前加载bash profile中的内容。


ALIAS

alias pd="pwd"

The alias command allows you to create keyboard shortcuts, or aliases, for commonly used commands.
alias命令允许你对于经常使用的命令创建键盘快捷键,或者说缩写。


CD

cd Desktop/

cd takes a directory name as an argument, and switches into that directory.
cd接受一个文件夹名作为参数,切换到该文件夹。

$ cd jan/memory

To navigate directly to a directory, use cd with the directory’s path as an argument. Here, cd jan/memory/ command navigates directly to the jan/memory directory.
如果想直接导航到某文件夹,在cd命令后接一个文件路径作为参数。在这个例子中cd jan/memory/ command导航到jan/memory文件夹。

CD ..

$ cd ..

To move up one directory, use cd ... Here, cd .. navigates up from jan/memory/ to jan/.
使用cd ..移动到上一级文件夹,cd ..jan/memory/ 导航到 jan/
CP

$ cp ada_lovelace.txt historical/

cp copies files or directories. Here, we copy the file ada_lovelace.txt and place it in the historical/ directory
cp命令用来复制文件或文件夹。在例子中我们复制了ada_lovelace.txt并把它放在historical/文件夹下


WILDCARDS (*)

$ cp * satire/

The wildcard * selects all of the files in the current directory. The above example will copy all of the files in the current directory to the directory called satire. There are other types of wildcards, too, which are beyond the scope of this glossary.
通配符*能匹配当前文件夹下的所有文件。上面的例子会把当前文件夹下所有文件复制到叫做satire的文件夹下。也有一些其他类型的通配符,但已经超出了本术语表的讨论范围。

$ cp m*.txt scifi/

Here, m*.txt selects all files in the working directory starting with “m” and ending with “.txt”, and copies them to scifi/.
在这里,m*.txt匹配当前文件夹下所有以“m”开头,以“.txt”结尾的文件,并复制到scifi/文件夹下。


ENV

env

The env command stands for “environment”, and returns a list of the environment variables for the current user.
env命令表示“environment”,并返回一个当前用户的环境变量列表。

ENV | GREP VARIABLE

env | grep PATH

env | grep PATH is a command that displays the value of a single environment variable.
该命令显示单个环境变量的值。

EXPORT

export USER="Jane Doe"

export makes the variable to be available to all child sessions initiated from the session you are in. This is a way to make the variable persist across programs.
export使得该变量对所有从当前会话中启动的子会话可用。这是一种使变量跨进程保持的方法。


GREP

$ grep "Mount" mountains.txt

grep stands for “global regular expression print”. It searches files for lines that match a pattern and returns the results. It is case sensitive.
grep 代表”global regular expression print”(全局正则表达式打印)。它在文件中搜索匹配模式的行并返回结果。是大小写敏感。

GREP -I

$ grep -i "Mount" mountains.txt

grep -i enables the command to be case insensitive.
grep -i使该命令大小写不敏感。

GREP -R

$ grep -R Arctic /home/ccuser/workspace/geography

grep -R searches all files in a directory and outputs filenames and lines containing matched results. -R stands for “recursive”.
grep -R检索一个文件夹下的所有文件,输出匹配模式的文件和行,-R表示“recursive”(递归)。

GREP -RL

$ grep -Rl Arctic /home/ccuser/workspace/geography

grep -Rl searches all files in a directory and outputs only filenames with matched results. -R stands for “recursive” and l stands for “files with matches”.
grep -Rl检索文件夹下的所有文件,只输出文件名和匹配结果,-R表示“recursive”(递归),l表示“files with matches”(带有匹配的文件)。


HOME

$ echo $HOME

The HOME variable is an environment variable that displays the path of the home directory.
HOME变量是一个展示home文件夹的路径的环境变量。


LS

$ ls
2014  2015  hardware.txt

ls lists all files and directories in the working directory
ls -a列出当前文件夹下全部文件和文件夹

ls -a

ls -a
.  ..  .preferences  action  drama comedy  genres.xt

ls -a lists all contents in the working directory, including hidden files and directories
ls -a列出当前文件夹下所有的内容,包括隐藏文件和文件夹

ls -l

ls -l
drwxr-xr-x 5  cc  eng  4096 Jun 24 16:51  action
drwxr-xr-x 4  cc  eng  4096 Jun 24 16:51  comedy
drwxr-xr-x 6  cc  eng  4096 Jun 24 16:51  drama
-rw-r--r-- 1  cc  eng     0 Jun 24 16:51  genres.txt

ls -l lists all contents of a directory in long format. Here’s what each column means.
ls -l以长格式列出当前文件夹下所有内容,这里是每一列代表的意思。

ls -t
ls -t orders files and directories by the time they were last modified.
ls -t根据文件的最后修改时间排序文件。


MKDIR

$ mkdir media

mkdir takes in a directory name as an argument, and then creates a new directory in the current working directory. Here we used mkdir to create a new directory named media/.
mkdir接收一个文件夹名作为参数,然后在当前目录下创建一个新文件夹。这里我们使用mkdir创建一个名为media/的文件夹。


MV

$ mv superman.txt superhero/

To move a file into a directory, use mv with the source file as the first argument and the destination directory as the second argument. Here we move superman.txt into superhero/.
把一个文件移动到文件夹中,使用mv并且把源文件作为第一个参数,目标文件夹作为第二个参数。这里我们把superman.txt移动到superhero/


NANO

$ nano hello.txt

nano is a command line text editor. It works just like a desktop text editor like TextEdit or Notepad, except that it is accessible from the the command line and only accepts keyboard input.
nano是一个命令行文本编辑器。它就像一个桌面编辑器(例如TextEdit或者Notepad)那样工作,除了它可以从命令行打开并且只接受键盘输入。


PATH

$ echo $PATH/home/ccuser/.gem/ruby/2.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin

PATH is an environment variable that stores a list of directories separated by a colon. Each directory contains scripts for the command line to execute. PATH lists which directories contain scripts.
PATH是一个保存一组文件夹的环境变量,用逗号分隔,每个文件夹包括一个命令行可以执行的脚本文件。


PWD

$ pwd
/home/ccuser/workspace/blog

pwd prints the name of the working directory
pwd打印出当前文件夹


RM

$ rm waterboy.txt

rm deletes files. Here we remove the file waterboy.txt from the file system.
rm删除文件。这里我们从文件系统中删除waterboy.txt这个文件。

RM -R

$ rm -r comedy

rm -r deletes a directory and all of its child directories.
rm -r删除一个文件夹及其所有子文件夹。


SED

$ sed 's/snow/rain/' forests.txt

sed stands for “stream editor”. It accepts standard input and modifies it based on an expression, before displaying it as output data.
sed表示”stream editor”,它接收一个标准输入,根据一个表达式修改它,然后作为输出数据展示。

In the expression 's/snow/rain/':
在表达式's/snow/rain/'中:
- s: stands for “substitution”. 表示替换
- snow: the search string, the text to find. 搜索字符串,需要找到的文字
- rain: the replacement string, the text to add in place. 替换的字符串,添加到找到的地方


SORT

$ sort lakes.txt

sort takes a filename or standard input and orders each line alphabetically, printing it to standard output.
sort 命令接收一个文件名或标准输出并按照字母对每一行进行排序,然后打印到标准输出。


STANDARD ERROR
standard error, abbreviated as stderr, is an error message outputted by a failed process.
标准错误,缩写为stderr,是一个运行失败的进程输出的错误信息。


SOURCE

source ~/.bash_profile

source activates the changes in ~/.bash_profile for the current session. Instead of closing the terminal and needing to start a new session, source makes the changes available right away in the session we are in.
source命令行可以为当前命令行会话激活~/.bash_profile,而无需关掉终端启动新的会话,source命令使得改变在当前所在的会话立即生效。


STANDARD INPUT
standard input, abbreviated as stdin, is information inputted into the terminal through the keyboard or input device.
标准输入,缩写为stdin,是通过键盘或输入设备输入到终端的信息。

STANDARD OUTPUT
standard output, abbreviated as stdout, is the information outputted after a process is run.
标准输出,缩写为stdout,是一个进程运行后的输出信息。


TOUCH

$ touch data.txt

touch creates a new file inside the working directory. It takes in a file name as an argument, and then creates a new empty file in the current working directory. Here we used touch to create a new file named keyboard.txt inside the 2014/dec/directory.
touch命令在当前文件夹下创建一个新文件。接收一个文件名作为参数,然后在当前文件夹下创建一个新的空文件。这里(教程中)我们用touch来在2014/dec/文件夹下创建名为keyboard.txt的新文件。

If the file exists, touch is used to update the modification time of the file
如果这个文件存在,touch可以用来更新文件的修改时间。


UNIQ

$ uniq lakes.txt

uniq, short for “unique”, takes a filename or standard input and prints out every line, removing any exact duplicates.
uniq是“unique”的缩写,接收一个文件名或标准输入作为参数,显示每一行并移除确切的重复(的行)。

codecademy 命令行手册(中英文)相关推荐

  1. 中兴zxr10路由器重启命令_中兴ZXR10系列路由交换机用户、命令行手册

    教程名称:中兴ZXR10系列路由交换机用户.命令行手册 课程目录: [IT教程网]2609A&2618A&2626A&2826A&2826A-PS用户手册上 [IT教程 ...

  2. 烽火2640路由器命令行手册-07-安全配置命令

    安全配置命令 目 录 第1章 AAA配置命令... 1 1.1 认证命令... 1 1.1.1 aaa authentication enable default 1 1.1.2 aaa authen ...

  3. MAC Iterm 支持命令行翻译中英文

    1.简介 遇到不认识的单词或需要翻译的中文还得打开浏览器百度翻译等进行翻译,今天来介绍自想的命令行翻译法.借用了github开源代码,自己改动了一下 2. 效果 image.png 3.实现步骤 cl ...

  4. 烽火2640路由器命令行手册-04-网络协议配置命令

    网络协议配置命令 目  录 第1章 IP寻址配置命令... 1 1.1 IP寻址配置命令... 1 1.1.1 arp. 1 1.1.2 arp timeout 2 1.1.3 clear arp-c ...

  5. 烽火2640路由器命令行手册-14-桥接配置命令

    桥接配置命令 目  录 第1章 VLAN配置命令... 1 1.1 二层交换VLAN配置命令... 1 1.1.1 vlan. 1 1.1.2 name. 2 1.1.3 switchport pvi ...

  6. 烽火2640路由器命令行手册-06-组播协议配置命令

    组播协议配置命令 目  录 第1章 基本组播配置命令... 1 1.1 基本组播配置命令... 1 1.1.1 debug ip mpacket 1 1.1.2 debug ip mrouting. ...

  7. 烽火2640路由器命令行手册-02-接口配置命令

    接口配置命令 目  录 第1章 接口配置命令... 1 1.1 接口配置命令... 1 1.1.1 async mode. 2 1.1.2 bandwidth. 3 1.1.3 cablelength ...

  8. 烽火2640路由器命令行手册-12-IBM网络配置命令

    IBM网络配置命令 目  录 第1章 DLSW配置命令... 1 1.1 DLSW配置命令... 1 1.1.1 dlsw local-peer 1 1.1.2 dlsw remote-peer 3 ...

  9. 烽火2640路由器命令行手册-11-IP语音配置命令

    IP语音配置命令 目  录 第1章 配置拨号对命令... 1 1.1 配置拨号对命令... 1 1.1.1 dial-peer voice. 1 1.1.2 application. 2 1.1.3 ...

  10. NSX edge命令行手册

    1.简介 NSX产品功能支持: NSXEdge设备使用相同的密码进入基本模式和特权模式.通过vSphere Web Client从NSX Manager部署NSX Edge设备时,系统将提示您配置密码 ...

最新文章

  1. 教您用CT数据和桌面3D打印机打印自己的器官模型
  2. 在Java中如何使用transient
  3. 成功解决Ubuntu下的include/darknet.h:14:14: fatal error: cuda_runtime.h: No such file or directory
  4. Delphi动态事件
  5. 解决 安装或卸载软件时报错Error 1001 的问题
  6. 关于Android 的内存泄露及分析
  7. python下批量修改图片格式和大小
  8. AM3352上移植sqlite3数据库
  9. C盘太小,调整磁盘分区大小
  10. conda添加清华镜像源
  11. 从零学前端第十七讲:小程序开发
  12. Educoder - Java类和对象之对象组合之求圆锥体表面积
  13. iOS 判断手机型号及系统版本(最新)持续更新
  14. php 字符串替换中文,PHP中文字符串替换其中为*的方法
  15. 机器学习:Linear Discriminant Analysis(过程详解+实例代码MATLAB实现
  16. 全国二级c语言库理论,全国计算机等级考试二级C语言理论基础习.doc
  17. 干货 | 区块链的可扩展性问题及解决方案对比
  18. 在Linux服务器上安装cmake遇到的小问题
  19. landsat7和8一级数据下载
  20. ORA-01502: index 'IPSP.SYS_C0014818' or partition of such index is in unusable state问题解决

热门文章

  1. CSS3硬件加速 - GPU加速
  2. Linux date 命令
  3. 移动开发期末大作业-备忘录app
  4. 读书笔记|从零开始做运营(入门篇)
  5. Typora编辑数学公式
  6. 资深 Googler 深度解读 TensorFlow
  7. 宝宝便秘,这些习惯都是元凶!
  8. MapReduce之简单K-mer计数
  9. 如何在Android上关闭YouTube烦人的自动播放缩略图
  10. index函数c语言,C语言数据结构中定位函数Index的使用方法