Mangling the IFS introduces a whole class of bugs into shell scripts that can and should be easily avoided...
Code:
#wrong, even with IFS hacks...
for file in `ls /some/dir`; do ...
#right, bug free, no IFS hacks needed...
for file in /some/dir/*; do ...
In your case:
Code:
#naughty IFS hacks...
oIFS="$IFS"
IFS=$'\n'
for line in `cat 'old_permissions'`; do
echo $line
done
#not necessary ...
cat old_permissions | while read line
do
echo "$line" #note below
done
Also note the quotation marks. At first glance in the following you may think that read is eating whitespace which is undesirable. But it's actually caused by the lack of quotes with the echo statement.
Code:
$ read line
test 123
$ echo $line
test 123
$ echo "$line"
test 123
Bookmarks