The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Small Search script appu1987 Shell Programming and Scripting 2 06-03-2008 07:14 PM
small script help ali560045 Shell Programming and Scripting 9 01-18-2008 06:18 AM
Very small Shell Script Help... marconi Shell Programming and Scripting 2 12-11-2007 01:44 AM
small script everurs789 Shell Programming and Scripting 3 11-06-2007 01:08 PM
small script help rkl1 Shell Programming and Scripting 1 12-06-2005 07:26 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-24-2005
Registered User
 

Join Date: Oct 2005
Posts: 6
Stumble this Post!
Need help in a small script

Hi all,

I have a file of the following format -

EXPRPT:SCN:1.1706E+10:SEQ_START:121652:SEQ_END:121664:0
( This file name is variable and changes daily)

Now in the same directory I have another set of files of the format -

EXPRPT.log.0001.0000121669

Now what I am trying to do is to

1. Parse the first file name and Get the number 121652 from the first file and then DELETE all the files of type EXPRPT.log.* where 6-7 digits of EXPRPT.log.* are lesser than number extracted from first file.

For example -

Let us say the following files are there -

EXPRPT.log.0001.0000121649
EXPRPT.log.0001.0000121651
EXPRPT.log.0001.0000121669
EXPRPT.log.0001.0000121670

Then only following files should be deleted as number 121652 is higher than numbers in these files.

EXPRPT.log.0001.0000121649
EXPRPT.log.0001.0000121651

Thanks for all your help.
Regards
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-24-2005
Registered User
 

Join Date: Jul 2005
Location: England
Posts: 183
Stumble this Post!
You should be able to modify the below code to suit your specific purposes

Code:
FILE="EXPRPT:SCN:1.1706E+10:SEQ_START:121652:SEQ_END:121664:0"

NUM=`echo $FILE | cut -d':' -f 5`

for file in `ls EXPRPT*`
do
  NUM2=`echo $file | cut -d'.' -f 4`
  if [ $NUM2 -lt $NUM ]
  then
    echo Removing $file
    rm -f $file
  fi
done
Reply With Quote
  #3 (permalink)  
Old 10-24-2005
Registered User
 

Join Date: Oct 2005
Posts: 6
Stumble this Post!
Excellent Solution !!!

Thanks a lot.

Tested it in one scenario. Works fantastically.

Regards
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0