Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Perl one-liner parsing
Name: lamos Date: November 9, 2007 at 09:56:45 Pacific OS: UNIX CPU/Ram: 2 Product: Solaris
Comment:
I've been trying to figure out how this Perl one-liner is suppose to work: perl -ne 'print "$1\n" if /rule\s\d/'
It's not working. It suppose to locate the word "rule" in the log file and output the rule # next to the word “rule” as listed in the URL.
Name: FishMonger Date: November 9, 2007 at 16:24:09 Pacific
Reply:
I'd need to see some example lines from your log file, but off hand I'd say the problem is that you're not using any quantifiers and you're not using parens to capture your data.
Try this:
perl -ne 'print "$1\n" if /(rule\s+\d+)/' file.log
Summary: I have modified my script and added some perl one liner and sed to parse the output line by line. $ a=`ls -lt ~/core_files| grep "^-" | awk '{Date_count=$6" "$7; freq[Date_count]++}END {for (date in ...
Summary: Use the echo command: example: echo path=USER /etc/host echo "the line your changing" then point to the path its in /etc/host (all as a one liner) ...