Posted by dandriff on Sunday June 29, 2008@10:43AM
Howto: Coax a BASH shell script into splitting for-loop elements by newline instead of whitespace (whitespace is the default behaviour).
#!/bin/bash IFS_BAK=$IFS IFS=" " for f in `ls -1 .`; do echo "I found a directory! => $d" done IFS=$IFS_BAK IFS_BAK=
This is really being posted for future reference by me, as I seem to keep forgetting that the "magic" variable name is IFS and not EOL.
Keywords: IFS, EOL, end of line, for-loop, newline, end-of-line,