Conversion of bash parsing script to perl?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Conversion of bash parsing script to perl?
# 1  
Old 10-11-2004
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
# 2  
Old 10-12-2004
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}++;
	}
}

# 3  
Old 10-13-2004
cbkihong,

Thanks for your help. Your script does exactly what I needed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing and Editing a json file with bash script

I am trying to automate editing of a json file using bash script. The file I initially receive is { "appMap": { "URL1": { "name": "a" }, "URL2": { "name": "b" }, "URL3": { "name": "c" }, } WHat I would like to do is replace... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

2. Shell Programming and Scripting

Conversion of Perl Script to Shell Script..

Hi Guys I am having a perl script that fetches exclude list from a unix client and I trying it to convert it to shell script but I am having issues please help me... #!/usr/bin/perl use strict; use warnings; use Getopt::Std; # To turn on debuging (i.e. more information) specify... (29 Replies)
Discussion started by: Pawan Ramnani
29 Replies

3. Shell Programming and Scripting

Help required for Oracle database shutdown script conversion from shell to perl

Please tell me how to convert below program from shell script to perl. Same commands need to use in shutdown, just need program help for startup. export ORACLE_BASE=/home/oracle1 lsnrctl start lndb1 sqlplus '/ as sysdba' startup; (2 Replies)
Discussion started by: learnbash
2 Replies

4. Shell Programming and Scripting

Error with Audio Conversion Bash Script

Good evening, I'm currently working on a BASH script to convert audio between file formats and I've come across a snag. At the beginning of the script, I'm having the system check to see if any files with the .m4a extension exist in the directory, and if so, it runs the script. If there are no... (1 Reply)
Discussion started by: KBurkholder
1 Replies

5. Shell Programming and Scripting

Column parsing in a bash script - HELP

I would like to setup a script that pulls in time/date in two seperate columns, and then name the other columns as listed below: Column1=Art/TJ output Column2=Art/TJ output Column3=TJ output column4=Art output Column5=If time/date past 12:00 noon -fail Colume6=If time/date before... (1 Reply)
Discussion started by: walnutpony123
1 Replies

6. Shell Programming and Scripting

Help parsing filename with bash script

Hi all! Looking for some help parsing filenames in bash. I have a directory full of files named "livingroom-110111105637.avi". The format is always date and time (yymmddhhmmss). I'm looking to parse the filenames so they are a little more easily readable. Maybe rename them to... (4 Replies)
Discussion started by: mtehonica
4 Replies

7. Shell Programming and Scripting

Bash XML Parsing using Perl XPath

I have a bash script that needs to read input from an XML file, which includes varying numbers of a certain type of child node. I want to be able to iterate through all the child nodes of a given parent. I installed the Perl XML-XPath package from search.cpan.org. Once it's installed, from bash,... (4 Replies)
Discussion started by: jfmorales
4 Replies

8. Shell Programming and Scripting

Encoding conversion in PERL script

I have oracle 9i database installed with UTF-8 Encoding. I want a perl script that converts unicode to utf8 before commiting in database and utf8 to unicode when retreiving from database For example : the word Ïntêrnatïônàlîzâtion has to be stored in database as Internationalization and when retreived... (6 Replies)
Discussion started by: vkca
6 Replies

9. Shell Programming and Scripting

Perl script parsing Help

Hi All, I am looking for a parsing in perl script which will parse DJEČJI SVIJET. There is a unicode character above character C. How to parse the total DJEČJI SVIJET in perl. Regards, Harikrishna (3 Replies)
Discussion started by: Harikrishna
3 Replies

10. UNIX for Dummies Questions & Answers

Another bash shell to perl conversion

Hello everyone. I am new to linux and need help again. I need help converting this bash shell to linux: for i in `ls -l *.txt` do `./cnvidtf.pl $i` `curl -u login:pswd --disable-espv -T loadfile.seq ftp://11.1.11.1` `mysql -u login -h 11.1.11.1 -ppswd < lddocs.sql` done Thanks! Any help... (6 Replies)
Discussion started by: freak
6 Replies
Login or Register to Ask a Question