Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Be careful of "special" characters' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Be careful of "special" characters
Authored by: a1291762 on Dec 28, '03 08:29:22PM
One of Unix's most annoying "features" is the treatment of special characters. You should be quoting any variable that should not be broken or otherwise interpreted differntly. A file/directory with a space could cause much havoc with your script. This is the same problem Apple had with the iTunes installer fiasco. Often it's just better to use something like perl, python, tcl, [insert your favourite scripting language here] instead of shell script when you're dealing with files named by users.

FYI - I would do something like the following to copy a file into many places:

for dir in /Users/*; do cp /path/to/file "$dir"; done

[ Reply to This | # ]