3 ms·
Alright, here's an example: touch 'file with spaces' for file in $(ls); do rm -- "$file" done This will not work, because $(ls) will get expanded to
by LambdaComplex 9y ago
Alright, here's an example:
touch 'file with spaces'
for file in $(ls); do
rm -- "$file"
done
This will not work, because $(ls) will get expanded to three items, not one. rm will be called on the files "file", "with", and "spaces"...which is not what was intended.
Now do this:
touch 'file with spaces'
for file in *; do
rm -- "$file"
done
This works correctly.
- aabbcc1241 9y agols -Q this will quote the file name for pipe operation
- LambdaComplex 9y agoStill doesn't work. touch 'file with spaces' for file in $(ls -Q); do echo "$file"; done This prints: "file with spaces"