几种符号的含义
方括号[] 表示可选;
大括号{} 表示必须;
尖括号<> 表示里面元素是必须的;
斜体 -sessionpassword session password 表示斜体部分必须被替换;
省略号 ... 表示前述元素(参数、值或信息)可以在命令行中多次重复;
管道符号 | 表示可以选择分隔符左边的元素,也可选择分隔符右边的元素。 在一次命令使用中不可同时选择两个元素。 在方括号中,这些选项是可选的。 在尖括号中,至少需要一个选项。
一个横杠和两个横杠的区别
一个横杠(Unix风格),例如
mysql -u root -p
或者
mysql -uroot -p
加不加空格看程序怎么才处理了,没有明确的规定。
两个横杠(GNU风格),使用两个连字符加上关键词(而不是单个字符)。这种风格的出现是因为有一些复杂的 GNU 程序,仅仅 26 个字母(或者算上大小写 52 个)不够使用而发展出来的。另外一个有点是容易理解,因为出现的不再是缩写的字母。选项参数可以使用空格分割也可以使用"="来分割。如:
ls --human-readable --sort=time
如果使用 Unix 风格,那么上条命令则是
ls -ht
举例说明下,命令tar --help
root@ubuntu:~/tar# tar --help
Usage: tar [OPTION...] [FILE]...
GNU 'tar' saves many files together into a single tape or disk archive, and can
restore individual files from the archive.
Examples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.
Main operation mode:
-A, --catenate, --concatenate append tar files to an archive
-c, --create create a new archive
-d, --diff, --compare find differences between archive and file system
--delete delete from the archive (not on mag tapes!)
-r, --append append files to the end of an archive
-t, --list list the contents of an archive
--test-label test the archive volume label and exit
-u, --update only append files newer than copy in archive
-x, --extract, --get extract files from an archive
-A等同于--catenate等同于--concatenate,将一个tar文件的内容追加至另外一个tar文件
--delete没有单个字符的简写,将某个文件从tar文件中删除,例如:
首先看b.tar中有end.c和d.c两个文件
root@ubuntu:~/tar# tar tvf b.tar
-rw-r--r-- root/root 475 2018-09-12 12:26 end.c
-rw-r--r-- root/root 19 2018-09-12 14:31 d.c
执行 tar --delete d.c -vf b.tar 后,b.tar中就只剩下end.c了。
root@ubuntu:~/tar# tar --delete d.c -vf b.tar