PDA

View Full Version : [Solved] sh reading line of log problem


itchibahn
December 14th, 2009, 18:17
I'm trying to read entire line into a variable, but seems the variable is returning each word.

The result I'm trying to get is
"block in quick all group 100"
But the below code is giving me:
"block"
"in"
"quick"
"all"
"group"
"100"

#!/bin/sh
#
for rules in `ipfstat -i | grep "group 100"` ; do
echo "$rules"
done

DutchDaemon
December 14th, 2009, 18:30
What's wrong with

ipfstat -i | grep "group 100"

?

DutchDaemon
December 14th, 2009, 18:31
If you really need a line-by-line approach:

ipfstat -i | grep "group 100" | while read line
do
echo ${line}
done

(this is a useless duplication though)

itchibahn
December 14th, 2009, 18:51
What's wrong with

ipfstat -i | grep "group 100"

?

Nothing wrong with that, I'm just trying to manipulate the string.

itchibahn
December 14th, 2009, 18:52
If you really need a line-by-line approach:

ipfstat -i | grep "group 100" | while read line
do
echo ${line}
done

(this is a useless duplication though)

This works. Exactly what I needed to manipulate each lines.
Thanks.