In Unix-like systems, the ASCII hyphen-minus is commonly used to specify options. The character is usually followed by one or more letters. Two hyphen-minus characters (--) often indicate that the remaining arguments should not be treated as options, which is useful for example if a file name itself begins with a hyphen, or if further arguments are meant for an inner command. Double hyphen-minuses are also sometimes used to prefix "long options" where more descriptive option names are used. This is a common feature of GNU software. The getopt function and program, and the getopts command are usually used for parsing command-line options.

Unix 风格:单个减号 -

在选项需要加参数的时候,紧跟在选项后面即可(或者加空格)。比如登录 mysql server 的时候:

$ mysql -u root -p

或者

$ mysql -uroot -p

均可。这时,root 就是 u 的参数,表示使用 root 用户登录。另外加不加空格看程序怎么才处理了,没有明确的规定。

GNU 风格:双减号 --

使用两个连字符加上关键词(而不是单个字符)。这种风格的出现是因为有一些复杂的 GNU 程序,仅仅 26 个字母(或者算上大小写 52 个)不够使用而发展出来的。另外一个有点是容易理解,因为出现的不再是缩写的字母。选项参数可以使用空格分割也可以使用"="来分割。如:

$ ls --human-readable --sort=time

如果使用 Unix 风格,那么上条命令则是

$ ls -ht

是不是更加易读呢?

X toolkit 风格

这是一种比较不常见的风格,使用单个连字符加上关键词。只有 X 相关的程序才使用这种风格,一般不建议使用。

$ xeyes -display joesws:0 -geometry 1000x1000+0+0

看上去和 GNU 风格差不多,只是双连字符改成了单个连字符。

https://en.wikipedia.org/wiki/Command-line_interface#Arguments

最新文章

  1. AC自动机 HDU 3065
  2. 在iPhone上同时关闭语音控制和siri的方法
  3. BZOJ 3112: [Zjoi2013]防守战线 [单纯形法]
  4. IOS block 循环引用的解决
  5. 【USACO 2.1】The Castle
  6. ArrayList的使用方法【转载】
  7. Oracle利用数据泵迁移用户
  8. 使用WebFrom来模拟一些MVC的MODEL与View的数据交互功能
  9. 谷歌识图、google识图如何知道图片相似?
  10. 教你用.Net来玩微信跳一跳
  11. Vue-cropper 图片裁剪的基本原理
  12. Linux安装TeamViewer
  13. (8)Microsoft office Word 2013版本操作入门_制作传单海报
  14. JS 获取链接中的参数
  15. Oracle课程档案,第十二天
  16. JFinal项目部署到Weblogic注意事项
  17. python day04作业
  18. 读jQuery源码释疑笔记3
  19. 表迁移工具的选型-复制ibd的方法-传输表空间
  20. Working routine CodeForces - 706E (链表)

热门文章

  1. Scala基础篇-02函数与代码块
  2. web调用手机相册,并实现动态增加图片功能
  3. vba,设置,excel,wps ,页面设置
  4. centOS linux 下PHP编译安装详解
  5. 利用nginx与nginx-rtmp-module搭建流媒体服务器实现直播
  6. Python之三元运算、集合、函数
  7. pdf 使用模板下载
  8. ubuntu 普通用户运行virt-manager时libvirt权限设置
  9. idea vue提示
  10. [css或js控制图片自适应]