linux命令格式及帮助

几种符号的含义

方括号[]       表示可选;

大括号{}      表示必须;

尖括号<>    表示里面元素是必须的;

斜体   -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 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值