Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have this shell command:

kill `cat -- $PIDFILE`

What the double -- does here? Why not use just

kill `cat $PIDFILE`
share|improve this question

1 Answer 1

up vote 16 down vote accepted

The -- tells cat not to try to parse what comes after it as command line options.

As an example, think of what would happen in the two cases if the variable $PIDFILE was defined as PIDFILE="--version". On my machine, they give the following results:

$ 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
share|improve this answer
3  
It is worth noting that this behavior (while very common) is defined by the receiving program (i.e. cat) and not by the shell. –  dmckee Feb 21 '10 at 2:33
    
@dmckee Very true, thanks. –  Mikael Auno Feb 21 '10 at 12:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.