ps -aux, with a '-'? without a '-'?

懒了 一直没写些什么。索性把刚才看到的豆知识记下来吧。


"ps -aux"命令经常用到,虽然他在我这里总是能够正常工作,但按照严格的语法,其实是应该写作 "ps aux"的。


执行ps -aux时,系统会提示一个警告:

 Warning: bad syntax, perhaps a bogus '-'?


看起来‘-’是不应该出现在这里的。但为什么是个Warning,而没有直接把用户晒在这呢。

来看看man里是怎么写的:

Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX standards require that "ps -aux" print all processes owned by a user named "x", as well as printing all processes that would be selected by the -a option. If the user named "x" does not exist, this ps may interpret the command as "ps aux" instead and print a warning. This behavior is intended to aid in transitioning old scripts and habits. It is fragile, subject to change, and thus should not be relied upon.


所以,除非哪天真碰上了一个叫做“x”的用户名,这个错误可能一直也不会被意识到。

既然已经知道了,以后就按规矩来。

posted on 2011-02-17 00:17  MILLIONhere  阅读(556)  评论(0)    收藏  举报