Andrew Watkins wrote:
> Come on folks! The first answer should be "What has this got to do
> with OpenSolaris?
> 
> But you are presuming that the file has only the 4 lines in it. What
> happens if the crontab is much longer
> 
> # more data here 0 0 * * * /usr/bin/true #Start of lines added by
> SUNWscu 20 4 * * 0 /usr/cluster/lib/sc/newcleventlog
> /var/cluster/logs/eventlog 20 4 * * 0
> /usr/cluster/lib/sc/newcleventlog /var/cluster/logs/DS # End of lines
> added by SUNWscu
> 
> try: % awk ' { if ( $0 ~ /^#Start of lines added by SUNWscu/ ) {
> START=1 } else if ( $0 ~ /^# End   of lines added by SUNWscu/ ) {
> START=0 } else if ( START==1 ) { print $0 }  } ' <filename>
> 
> Andrew

Actually, awk has built-in support for this idiom:

        awk '/Start.*SUNWscu/,/End.*SUNWscu/'

will do the same thing.

Daniel Rock pointed out in another email that sed supports this syntax also.

        Scott

_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to