for-loop.sh
#!/bin/bash
# Should do the same as:
# ls | read f; do echo $f; done
# ...but without starting a new shell
# DOES NOT WORK PROPERLY!
#================
# Alternative #1:
IFS=$(echo);
for file in $(ls); do
echo $file;
done
exit;
#================
# Alternative #2:
for tmp in $(ls | perl -pe's/\s/\x1/g; $_.=" "'); do
file=$(echo $tmp | perl -pe's/\x1/ /g; s/\s$//;');
echo $file;
done;