Re:Exa, a modern replacement for ls
by LambdaComplex on Thursday August 10, 2017 @02:18PM
(#14982550)
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.
Re:Exa, a modern replacement for ls
by aabbcc1241 on Friday August 11, 2017 @10:23PM
(#14996032)
ls -Q
this will quote the file name for pipe operation
Re:Exa, a modern replacement for ls
by LambdaComplex on Sunday August 13, 2017 @03:28PM
(#15004473)
Still doesn't work.
touch 'file with spaces'
for file in $(ls -Q); do echo "$file"; done
This prints: "file
with
spaces"
In the meantime, I recommend you try deleting /bin/ls from your system and then filing bugs against everything that breaks.