![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|