i need to grep a STRING_A & the next few lines after the STRING_A
example file:
STRING_A yada yada
line 1
line 2
STRING_B yada yada
line 1
line 2
line 3
STRING_A yada yada
line 1
line 2
line 3
line 4
STRING_A yada yada
line 1
line 2
line 3
line 4
line 5
line 6
as u can see the line might be vary. sometime 2 lines, sometime 4 or 6 lines. any suggestion?
The above script is not working if i put it in a script
cat testing.ksh
p=$\p
cat testing.cfg|while read extractdata
do
whattext=`echo $extractdata|awk -F"||" {'print $1'}`
howmanylines=`echo $extractdata|awk -F"||" {'print $2'}`
echo "sed -n '/${whattext}/,$p' extractedmessage.out|head -${howmanylines}|tail -1"
output1is=`sed -n '/${whattext}/,$p' extractedmessage.out|head -${howmanylines}|tail -1`
echo ${output1is}
done
but if i cut and paste outout of the sed and run it manuall it works fine
$ sed -n '/LAST_UPDATED_DATE/,$p' extractedmessage.out|head -2|tail -1
06-APR-08
Any help will be greatly appreciated.
Thanks in advance
arun
hi gurus,
I am trying to use sed to get certain line after a requested line.
the sed works if i run manually but if i put it through shell it does not work.
example file:
STRING_A yada yada
line 1
line 2
STRING_B yada yada
line 1
line 2
line 3
STRING_A yada yada
line 1
line 2
line 3
line 4
STRING_A yada yada
line 1
line 2
line 3
line 4
line 5
line 6
What if you want each of the STRING_A yada yada and its respective following lines sent to a unique file for each?
as such...
STRING_A yada yada
line 1
line 2
sent to somefile1.txt
STRING_A yada yada
line 1
line 2
line 3
line 4
sent to somefile2.txt
and
STRING_A yada yada
line 1
line 2
line 3
line 4
line 5
line 6
sent to somefile3.txt