awk or perl print feilds after regex.
Is there a way in awk or perl to just print everything including and after the 'sh'
This text file had the ip and host names edited out. The filed are not all uniform - I can't use the stardard awk print out $1 $4 and $5 fields, because the information in each field is not consistent. Code:
Jan 26 03:00:03 corectld: client casperhost:36121: exec: sh -c "ping -c 3 172.18.47.1" |
Are you looking for something like this:
Code:
awk -F" sh" '/sh/{ print $2 }' infile Code:
sed -n 's%.*exec: sh%%p' infile |
Quote:
Easily fixed: Code:
awk -F" sh" '/sh/{ print "sh"$2 }' infile |
In perl (untested)
Code:
#! /usr/bin/perl -w |
Code:
grep -o 'sh -c.*$' infile |
All times are GMT -5. The time now is 12:16 AM. |