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
help - script can check jump sequence? happyv Shell Programming and Scripting 10 2 Weeks Ago 05:59 PM
checking the smallest and largest number subin_bala Shell Programming and Scripting 4 04-24-2008 04:32 AM
Sequence number generation on a key column sbasetty Shell Programming and Scripting 6 03-27-2008 09:09 AM
checking invoice number not correct happyv Shell Programming and Scripting 8 03-29-2007 02:07 AM
sequence number checking nhatch UNIX for Dummies Questions & Answers 1 04-24-2003 11:25 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-18-2006
Registered User
 

Join Date: Sep 2006
Posts: 209
checking jump sequence number (part2)

The following script have some bug...can you all help me:

#!/bin/sh
start=1
for file_number in `ls -1 /appl/CH_DATA/archive/list1/CACHE/CDBACKUPFILEJohn*.archived | sort | cut -c 48,49,50,51`
do
if [ $start -eq 1 ] ; then
# this is the first pass of the loop, so we've got nothing to compare
start=0
previous=$file_number
else
# this is not the first pass of the loop
previous=`expr $previous + 1`
#echo "comparing $file_number and $previous ... "
if [ $file_number = $previous ] ; then
echo "ok"
else
echo "file names $file_number are not in sequence "
fi
fi
previous=$file_number
done


For the above, I have problem to list CD*.archived in directory, because of I have same filename with *.archived and *_bup.archived.

1 - I just want to list out CD*.archived
2 - I have alot filename like CDBACKUPFILEJohn*, CDBACKUPFILEMARRY*, CDBACKUPFILEPETER*, etc. Can I put all name into the name.txt and
the script can read the name.txt and put into the scrip like CDBACKUPFILE$name?

Thanks!!
Reply With Quote
Forum Sponsor
  #2  
Old 10-19-2006
justsam's Avatar
Registered User
 

Join Date: Oct 2006
Location: Bangalore,India
Posts: 37
If you dont want _bup.archived, use grep -v option in the ls command .


ls -1 /appl/CH_DATA/archive/list1/CACHE/CDBACKUPFILEJohn*.archived | grep -v _bup.archived | sort | cut -c 48,49,50,51
Reply With Quote
  #3  
Old 10-19-2006
Registered User
 

Join Date: Sep 2006
Posts: 209
Quote:
Originally Posted by justsam
If you dont want _bup.archived, use grep -v option in the ls command .


ls -1 /appl/CH_DATA/archive/list1/CACHE/CDBACKUPFILEJohn*.archived | grep -v _bup.archived | sort | cut -c 48,49,50,51

Thank's it work! How about the filename "John" can I read from the list.txt (because of over 300 different filename) and check the seq?
Reply With Quote
  #4  
Old 10-19-2006
Registered User
 

Join Date: Sep 2006
Posts: 209
I have a list.txt (over 300 name) like:

john
marry
peter
annie

can my script read it and put into like "CDBACKUPFILEjohn*.archived", "CDBACKUPFILEmarry*.archived" to check jump seq number?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:47 AM.


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

Content Relevant URLs by vBSEO 3.2.0