Perl script to scan through files | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Perl script to scan through files

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-05-2008
gholdbhurg gholdbhurg is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 25 February 2009, 12:17 PM EST
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
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 position 560-580
Ex: Position620-640 = 00000002000000.000000
Position560-580 = 00000005000000.000000

Thanks in advance
Sponsored Links
    #2  
Old 03-05-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
 
Join Date: Nov 2007
Last Activity: 23 April 2014, 9:50 PM EDT
Location: New Zealand
Posts: 1,028
Thanks: 19
Thanked 22 Times in 21 Posts
Java


Code:
#!/bin/sh
while read line
do
  if [ "`echo $line | cut -c 10-13`" = "ABCD" -a `echo $line | cut -c 620-640` -lt `echo $line | cut -c 560-580` ]
  then
    echo $line >> /tmp/$$.txt
  fi
done
if [ -r /tmp/$$.txt ]
then
  /your/favourite/email/program you@wher.you.are < /tmp/$$.txt
  rm /tmp/$$.txt
fi

Untested
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Scan two files and print values missing shaliniyadav Shell Programming and Scripting 6 06-30-2010 08:37 AM
A script to scan a directory for XML files, apacheuk Shell Programming and Scripting 3 12-18-2009 05:50 AM
Script to Scan proclog files deeprajn95 Shell Programming and Scripting 3 05-12-2008 06:25 AM
Scan Multiple Dir/Files tonyd UNIX for Dummies Questions & Answers 7 03-30-2008 03:52 AM
Perl script to scan back lines gholdbhurg Shell Programming and Scripting 3 03-18-2008 12:33 PM



All times are GMT -4. The time now is 03:10 PM.