我有这个shell命令:
kill `cat -- $PIDFILE`
Run Code Online (Sandbox Code Playgroud)
什么双 - 在这里?为什么不只使用
kill `cat $PIDFILE`
Run Code Online (Sandbox Code Playgroud)
Mik*_*uno 24
该--通知cat不尝试分析后,随之而来的命令行选项。
举个例子,想想如果变量$PIDFILE被定义为 ,在这两种情况下会发生什么PIDFILE="--version"。在我的机器上,他们给出以下结果:
$ cat $PIDFILE
cat (GNU coreutils) 6.10
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Torbjorn Granlund and Richard M. Stallman.
$ cat -- $PIDFILE
cat: --version: No such file or directory
Run Code Online (Sandbox Code Playgroud)