Hi awk and sed gurus,
Please help me in the following.
I have the following entries in the file
ABCDErules
AbHDPrules
ABCrules
--
--
and other entries in the file.
Now, I want to extract from the file that contain entries for *rules and process it separately.
How can i do it with sed or awk command. Please help.
-San
clx
April 14, 2010, 2:13am
2
Do you want to filter the lines which contains "rules"?
Please post the expected output from the above sample. and how do you want to process them.
Reboot
April 14, 2010, 2:13am
3
hi use following :
for i in `grep 'rules$' filename`
do
......
......
done
Hope this is what u are looking for...
I want to extract this output to some variable and process one by one using for loop.
ABCDErules
AbHDPrules
ABCrules
clx
April 14, 2010, 2:35am
5
awk '/rules$/ { -- process for each line here -- }' file
or,
while read line
do
found=$(echo $line | grep 'rules$')
if [ "$found" ]; then
# do process
else
echo 'no found'
fi
done < file
or grep/awk/sedless:
while read line
do
case $line in
*rules) echo "$line"
esac
done < infile
@ Scrutinizer and @ anchal_khare
Thanks a lot, it worked with little modification. Since i don't want full line. just only the first field. so i printed the first field after filtering the entire line.