Is there any established order for 'ls' arguments?

杀马特。学长 韩版系。学妹 提交于 2019-12-01 19:48:48

See POSIX utility syntax guidelines, entry #9:

Guideline 9:

All options should precede operands on the command line.

Thus, the usage that POSIX guarantees will be supported is ls -R ., as -R is an option, and . is an operand.

GNU tools don't generally enforce this guideline (which is why Arch lets you put your arguments in the opposite order) -- but for maximum portability it's wise to write your software assuming it to be enforced.

If you want to be certain that -R will be treated as an operand rather than an argument, whatever your platform, you can use -- to separate the two categories: ls -l -- -R will treat -l as an option and -R as an operand, and thus will look for a file or directory named -R and provide a long-format listing; this is defined by POSIX utility syntax guideline #10.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!