Hi
I am a rookie and I would like to know how to make a script that prints as a output lines between two lines let say first variable is a :
Mon Aug 31 09:00:00 2009 CET
and the last line is
Tue Sep 08 09:00:00 2009 CET
also
lets say third line from
Mon Aug 31 09:00:00 2009 CET
thanks in advance I would realy apreciate the help
What do you have so far?
For the first part I have a solution which was realy simple:
a script that prints as a output lines between two lines let say first variable is a :
and it is :Mon Aug 31 09:00:00 2009 CET
and the last line is
Tue Sep 08 09:00:00 2009 CET
awk '/Mon Aug 31 09:00:00 2009 CET/,/Tue Sep 08 09:00:00 2009 CET/' file
but for the second part printing a specific line after a matched line I am still trying to figure out ...
If I understand you correctly, you want to print everything between two lines but not the two lines themselves.
If so, this script ought to do it
Code:#!/bin/bash if [ $# -lt 1 ] then exit fi bolle=0 beginstr="three" endstr="seven" if [ -e $1 ] then for line in $(cat $1) do if [ $line == $endstr ] then bolle=0 fi if [ $bolle -eq 1 ] then echo $line fi if [ $line == $beginstr ] then bolle=1 fi done else echo no existo fi
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks