![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing variable from bash to perl from bash script | arsidh | Shell Programming and Scripting | 10 | 06-04-2008 12:25 PM |
| Another bash shell to perl conversion | freak | UNIX for Dummies Questions & Answers | 6 | 05-29-2008 01:04 PM |
| HTML parsing by PERL | avik1983 | Shell Programming and Scripting | 3 | 02-23-2007 09:25 AM |
| bash to perl conversion | thumper | Shell Programming and Scripting | 2 | 07-14-2006 03:36 PM |
| Perl conversion & perldoc question | thumper | Shell Programming and Scripting | 2 | 09-11-2005 09:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Conversion of bash parsing script to perl?
I need help with a perl parsing script. I have some error logs on a windows machine that I need to parse from a text file, but I know nothing about perl. I usually run this bash script on my linux box and it does just what I need. How would I do the same thing with perl and port it to my windows machine. Thanks.
#!/bin/bash grep ERROR $1 | cut -d" " -f2- | sort | uniq -c |
|
||||
|
Try something like this:
Code:
#!/usr/bin/perl
open FILE, "<" . $ARGV[0];
@arr = ();
while (chomp($line = <FILE>)) {
if ($line =~ /ERROR/) {
@fields = split(/ /, $line);
shift @fields;
$key = join(' ', @fields);
push @arr, $key;
$count{$key}++;
}
}
|
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|