This example won't make much sense unless you're coming from the Useless Use of Cat Award Page
(Tip: Create a temporary directory under$ # Create file names with spaces in them $ touch "moo bar" $ touch "foo bar baz" $ ls -1 * foo bar baz moo bar $ # Try to list them in a for loop $ for f in *; do ls $f; done ls: foo: No such file or directory ls: bar: No such file or directory ls: baz: No such file or directory ls: moo: No such file or directory ls: bar: No such file or directory $ # Okay, try with double quotes around $f instead $ for f in *; do ls "$f"; done foo bar baz moo bar $ # Now demonstrate the bad impact of the backticks $ for f in `echo *`; do ls $f; done ls: foo: No such file or directory ls: bar: No such file or directory ls: moo: No such file or directory ls: bar: No such file or directory ls: baz: No such file or directory $ # Even the double quotes don't help anymore: $ for f in `echo *`; do ls "$f"; done ls: foo: No such file or directory ls: bar: No such file or directory ls: moo: No such file or directory ls: bar: No such file or directory ls: baz: No such file or directory $ # Getting desperate sure doesn't help any either: $ for f in "`echo *`"; do ls "$f"; done ls: foo bar baz moo bar: No such file or directory
/tmp
for small
experiments like this. Remember to clean up after yourself when you're
done.)