这个命令中的“--”是什么意思 xargs 命令
Whats's this "--" for in this command xargs command
在 Unix 中,
ls -t | tail -n +4 | xargs rm --
ls -t | tail -n +4 | xargs rm
请问有什么区别?
What's this “--” for in this command xargs command
--
表示"switches end here"
--
表示命令行上的所有后续参数都被视为操作数而不是选项(即使参数以 -
或 --
开头)。
因此,ls -t | tail -n +4 | xargs rm --
意味着 xargs
提供给 rm
的所有参数都将被视为文件名(即操作数)。
而在ls -t | tail -n +4 | xargs rm
情况下,如果在当前目录中碰巧有一个以-
或--
开头的文件名,rm
将尝试将其解释为一个选项(并且很有可能出现意想不到的结果)。
在 Unix 中,
ls -t | tail -n +4 | xargs rm --
ls -t | tail -n +4 | xargs rm
请问有什么区别?
What's this “--” for in this command xargs command
--
表示"switches end here"
--
表示命令行上的所有后续参数都被视为操作数而不是选项(即使参数以 -
或 --
开头)。
因此,ls -t | tail -n +4 | xargs rm --
意味着 xargs
提供给 rm
的所有参数都将被视为文件名(即操作数)。
而在ls -t | tail -n +4 | xargs rm
情况下,如果在当前目录中碰巧有一个以-
或--
开头的文件名,rm
将尝试将其解释为一个选项(并且很有可能出现意想不到的结果)。