The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 10:14 PM
small script help ali560045 Shell Programming and Scripting 9 01-18-2008 10:18 AM
Very small Shell Script Help... marconi Shell Programming and Scripting 2 12-11-2007 05:44 AM
small script everurs789 Shell Programming and Scripting 3 11-06-2007 05:08 PM
small script help rkl1 Shell Programming and Scripting 1 12-06-2005 11:26 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-24-2005
super_duper_guy super_duper_guy is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 6
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
  #2 (permalink)  
Old 10-24-2005
Unbeliever Unbeliever is offline
Registered User
  
 

Join Date: Jul 2005
Location: England
Posts: 183
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
  #3 (permalink)  
Old 10-24-2005
super_duper_guy super_duper_guy is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 6
Excellent Solution !!!

Thanks a lot.

Tested it in one scenario. Works fantastically.

Regards
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0