View Single Post
  #3   (View Single Post)  
Old 30th November 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,131
Default

A simple demonstration how quoting a variable prevents the shell from breaking up a variable value containing whitespaces
Code:
$ FILE="name with spaces"
$ cat $FILE
cat: name: No such file or directory
cat: with: No such file or directory
cat: spaces: No such file or directory
Here the shell breaks up the value of the FILE variable into 3, and passes them to the cat utility. Because cat accepts multiple files, it first tries to display file "name", then file "with" and file "spaces". Because these files don't exist, we see cat issueing three error messages.

The same command but now using a quoted FILE variable
Code:
$ cat "$FILE"
cat: name with spaces: No such file or directory
Now cat only gives one single message: there is no file "name with spaces".
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote