Within a bash script, I'm trying to feed each line of a file into a
variable, to wit:
for line in `cat file`
do
do_whatever
done
At the end of this operation, I want the $line variable to equal the
contents of a single line in the file. The problem is that the shell
breaks the line into _words_ if there are any spaces, tabs or newlines
in it. I understand why. It's because of the value of the IFS shell
variable. To get around this, I want to set the IFS variable to be
_only_ the newline. But I can't find a way to do it. The following do
not work:
IFS=
IFS=\n
IFS='\n'
IFS="\n"
So how do I get $line in the example above to be equal to a single line
of the file for each iteration?
Paul
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:12:48 EDT