B"H
On 6/7/06, John Oliver <[EMAIL PROTECTED]> wrote:
When I use the output of catting a file as the variable in a for-then
loop, the output of cat is broken along all spaces.  So, a line in a
file like:

71.112.211.167 - - [01/Jun/2006:00:03:06 -0700] "GET
/BENBRYAN-NEIL-BENB-RYAN-IMPACTENGINE/44/44211E9A-8412-61EC-E6F2-CC89F84887F6/gallery/image/9844/image.swf
HTTP/1.1" 200 4151 "-"

when called out like:

for i in $(cat /tmp/test.log); do echo $i; done


Why, and how do I keep the line whole?


Try this:

-----
for i in $(cat /tmp/test.log); do echo "$i"; done
-----

and if that doesn't work try a shell script like this:

--------
#!/bin/bash

IFS=$'\t\n'    #get rid of the space in the IFS variable
for i in $(cat /tmp/test.log)
do
   echo $i
done
--------

And if that doesn't work, you can always try this (this works for me
on the really stripped down shells):

--------
#!/bin/bash

IFS="
"      # this is a linebreak in quotation marks
for i in $(cat /tmp/test.log)
do
   echo $i
done
--------

Menachem

--
***********************************************************************
* John Oliver                             http://www.john-oliver.net/ *
*                                                                     *
***********************************************************************


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list



--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to