jisha
1
Hi,
I want to print only lines in between two strings and not the strings using awk.
Eg:
OUTPUT
top 2
bottom 1
left 0
right 0
page 66
END
I want to print into a new file only
top 2
bottom 1
left 0
right 0
page 66
Thanks in Advance
JS
awk /OUTPUT/,/END/ filename|grep -v 'OUTPUT^JEND'
or
awk /OUTPUT/,/END/ filename|grep -v 'OUTPUT
END'
there's a standard algo for doing this. turning on/off a flag
f=0
while read line
do
case $line in
OUTPUT*) f=1; continue ;;
END* ) f=0
esac
if [ "$f" -eq 1 ]; then
echo $line
fi
done < "file"
In awk:
awk ' /OUTPUT/ {flag=1;next} /END/{flag=0} flag { print }' file
Hi,
I think this one is easy.
sed -e '1,/OUTPUT/d' -e '/END/,$d' file
1 Like