Sponsored Content
Top Forums Shell Programming and Scripting Perl script to scan back lines Post 302176518 by jim mcnamara on Tuesday 18th of March 2008 12:10:39 PM
Old 03-18-2008
consider and awk version:
Code:
csadev:/home/jmcnama> cat t.awk   
awk -F, 'BEGIN { give=""}
         {
            if($4 ~ /give/){
                  give=sprintf("%s%,%s" ,
                        substr($4, length($4)-3),
                        substr($5, length($5)-3 ) )
                  }
            if($4 ~ /This is not a valid dealing/) {
                printf("ERROR: %s (%s)\n", $2, give)
                }
         } ' filename

csadev:/home/jmcnama> cat filename
2008031A, USERNAME, 12345, give ABC, take XYZ, transaction submitted
2008031B, USERNAME, 12346, waiting for processing
2008031C, USERNAME, 12347, Retrieving response
2008031D, USERNAME, 12348, This is not a valid dealing
2008031E, USERNAME, 12349, State has failed
2008031F, USERNAME, 12350, System=0
2008031G, USERNAME, 12351, Waiting for new txns
2008031H, SOMEONE, 12352, give STE, take GVO, transaction submitted
2008031I, SOMEONE, 12353, waiting for processing
2008031J, SOMEONE, 12354, Retrieving response
2008031K, SOMEONE, 12355, This is not a valid dealing
2008031L, SOMEONE, 12356, State has failed
2008031M, SOMEONE, 12357, System=0
2008031N, SOMEONE, 12358, Waiting for new txns

csadev:/home/jmcnama> t.awk
ERROR:  USERNAME ( ABC, XYZ)
ERROR:  SOMEONE ( STE, GVO)

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to scan only new lines added in file?

Hi, I am planning to implement a scheduled script that will go against my log files (every hour), search for a set of key words (errors, exceptions, faults etc). The script must be intelligent enough to scan only the new lines added to the log file since it last ran. I can use grep for... (3 Replies)
Discussion started by: redlotus72
3 Replies

2. Shell Programming and Scripting

Perl script to scan through files

Dear perl gurus, I plan to create a script that will scan through a logfile line by line. And if ever a certain line meets the below conditions, it will alert me via email. --> a) Position 10 to 13 = "ABCD" b) And also if the amount specified in position 620-640 is less than the amount in... (1 Reply)
Discussion started by: gholdbhurg
1 Replies

3. UNIX for Dummies Questions & Answers

Perl/shell script count the lines

Hi Guys, I want to write a perl/shell script do parse the following file input file content NPA-NXX SC 2084549 45 2084552 45 2084563 2007 2084572 45 2084580 45 3278411 45 3278430 45 3278493 530 3278507 530... (3 Replies)
Discussion started by: pistachio
3 Replies

4. Shell Programming and Scripting

[Help] PERL Script - grep multiple lines

Hi Gurus, I need some help with the "grep" command or whatever command that you think suitable for me. I'm about to write a perl script to extract a report from the system and submit it to the end users. The input for the script will consist of 3 element. 1) Generation ID 2) Month 3) Year... (6 Replies)
Discussion started by: miskin
6 Replies

5. Shell Programming and Scripting

Perl script that counts lines of a file

I am working on this script, but hit a bump. Looking for a little help figuring out the last part: open(MY_FILE, $ARGV) or die $COUNTER = 1; $LINE = <FILE>; while ($LINE, <FILE>) { # Adds leading zeros for numbers 1 digit long if ($COUNTER<10){ print "000"; } # Adds... (2 Replies)
Discussion started by: Breakology
2 Replies

6. Shell Programming and Scripting

Perl - need script for modify lines

Hello, does somebody can make script for me, which replace: ąćę ąćę ąćę (input file) to ace;|;ąćę ace;|;ąćę ace;|;ąćę (output file) (3 Replies)
Discussion started by: Xadrian
3 Replies

7. Shell Programming and Scripting

perl script print the lines between two pattern

i have a file as below sample.pl parameter1 argument1 argument2 parameter2 I want out as below argument1 argument2 that is , i want to print all the lines between parameter1 & parameter 2. i tried with the following if($mystring =~ m/parameter1(.*?)parameter2/) (2 Replies)
Discussion started by: roopa
2 Replies

8. Shell Programming and Scripting

Scan a file in realtime and execute certain commands on encountering 5 consecutive identical lines

Mysql log has something like below: I need a bash shell script that will do the following: 1) The script will scan the mysql.log file constantly in real time (something like tail -F mysql.log) 2) If it encounters 5 consecutive identical lines then it would invoke some commands (say... (4 Replies)
Discussion started by: proactiveaditya
4 Replies

9. Shell Programming and Scripting

Scan for anchor tags in Perl?

Hello all, I have some .html files on my hard drive and trying to figure out (if it's possible) how to scan the files in the directory for <a> anchor tags to find linked files. I know how to bring the files in with Perl, but as text. Wondering if there's a way to probe the file for... (2 Replies)
Discussion started by: sldsand
2 Replies

10. Shell Programming and Scripting

Perl script: matching multiple lines error

Dear Perl users, Could somebody help me how to fix my code so I can get my desired output. Here is the data: Pattern Gabriel halo1 halo2 end Pattern Andreas halo1 halo2 endI want to grep multiple lines between the pattern /Pattern Gabriel / and /end/. Then I will store the output into... (6 Replies)
Discussion started by: askari
6 Replies
JSONBOT(1)							    jsb manual								JSONBOT(1)

NAME
jsb-convore - The JSONBOT convore program SYNOPSIS
jsb-convore is a bot for the convore group chat network built on the JSONBOT framework. DESCRIPTION
jsb-convore connects to a convore group in much the same way as jsb-irc connects to an IRC channel. USAGE
Usage: jsb-convore [options] Options: --version show program's version number and exit -h, --help show this help message and exit -d DATADIR, --datadir=DATADIR datadir of the bot -o OWNER, --owner=OWNER owner of the bot -l LOGLEVEL, --loglevel=LOGLEVEL loglevel of the bot -p PASSWORD, --password=PASSWORD set password used to connect to the server -c CHANNEL, --channel=CHANNEL channel to join --name=NAME bot's name -u USERNAME, --username=USERNAME username of the bot DOCUMENTATION
See http://jsonbot.org for more documentation or see http://jsonbot.googlecode.com SEE ALSO
jsb(1), jsb-backup(1), jsb-init(1), jsb-irc(1), jsb-xmpp(1), jsb-fleet(1), jsb-sed(1), jsb-tornado(1), jsb-stop(1), jsb-udp(1), jsonbot(1) AUTHOR
This manual page was written by Jeremy Malcolm <terminus@debian.org>, for the Debian GNU/Linux system (but may be used by others). Debian GNU/Linux 22 Nov 2011 JSONBOT(1)
All times are GMT -4. The time now is 07:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy