[TriLUG] bash cmd line processing question
Andrew Perrin
andrew_perrin at unc.edu
Thu Feb 14 13:32:18 EST 2002
On Thu, 14 Feb 2002, M. Mueller (bhu5nji) wrote:
> why does the following command work:
>
> $kill -SIGHUP `cat /var/run/syslogd.pid`
Backticks (``) mean "execute the command in the backticks and pass the
result back." So in this case, kill gets two arguments: -SIGHUP and
the STDOUT stream from the command:
cat /var/run/syslogd.pid
which is, presumably, the PID of the syslogd process; it is whatever the
contents of /var/run/syslogd.pid are.
>
> why does the following command *not* work:
>
> $kill -SIGHUP 'cat /var/run/syslogd.pid'
>
Regular quotes ('') mean "treat the contents as a single argument instead
of breaking them up in normal shell parsing manner." Again, kill gets two
argument: -SIGHUP and the string:
cat /var/run/syslogd.pid
which is, with some certainty, not a PID (since PID's are numeric and "cat
/var/run/syslogd.pid" is not).
Hope this helps.
----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin at unc.edu - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA
More information about the TriLUG
mailing list