Swansong wrote: > > I'm fairly certain I'm attacking this incorrectly, so any advice is > greatly appreciated... > > Task: > > I want to sort through my Solaris syslog (/var/adm/messages) looking for > any system reboots which always start with the string SunOS and, if > found, return that line and the next 20 lines, at least for starters. > > I was going to try and catch the line # of the line that has the SunOS > in it and then increment that by 1, print that line from the array and > then increment by 1 for 20 iterations. > > I scratching out something such as.....(I'm a complete newbie and I'm > banging my head against the wall because either I'm completely > attacking this with the wrong logic and/or I'm misinterpreting the usage > of $. ......me thinks...help please...) > > #!/usr/local/bin/perl -w
#!/usr/local/bin/perl -w use strict; > $file="/var/adm/messages"; my $file = '/var/adm/messages'; > printf "test of the emergency broadcast system\n"; print "test of the emergency broadcast system\n"; > open (FILE, "< $file") or die "can't open $file: $!"; while ( <FILE> ) { if ( /SunOS/ ) { print; print scalar <FILE> for 1 .. 20; } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]