University Crest

[wlug] Removing /-rf

wlug archive index About the wlug list Mailing lists home
To The University of Waikato HomepageWaikato Home > Waikato Mailing Lists > wlug Info > wlug archives
Oliver Jones oliver@d...
Sat Apr 9 14:03:48 NZST 2005

On Sat, 2005-04-09 at 11:38 +1200, Bnonn wrote:

> Stink. I wasn't game enough to give it a go. What's the point of
> demarcating things if the command doesn't recognize the demarcation
> though...?

For one, it is bash that you're telling special things to when you quote
strings, not the command you're passing arguments too.  In the previous
case rm would just have received the string -rf (without quotes) as argv
[1].  The only reason to quote arguments is to ensure special characters
are not misinterpreted by your shell.  eg:

rm "file with spaces.txt"


rm 'file with $sign and spaces.txt'


rm 'file with bang!.txt'

An alternative to quoting is escaping.  Eg:

rm file\ with\ bang\!.txt

You will find that bash does this by default if you tab complete a file
with a funny name like the above.

The difference between " (double) and ' (single) quotes is that with
double quotes your shell will interpolate environment $vars and other
shell special characters.  Eg:

$ echo "There's no place like $HOME."
There's no place like /home/oliver.

Where as with single quotes this doesn't happen.

$ echo 'There is no place like $HOME.'
There is no place like $HOME.

Of course all of this is only guaranteed to apply to bash, my shell of

                   Oliver Jones » Roving Code Warrior
   oliver@d... » +64 (21) 41 2238 » 

More information about the wlug mailing list
NOTICE: This is an archive of a public mailing list. The University of Waikato is not responsible for its contents.

The University of Waikato - Te Whare Wananga o Waikato