Re: Sort files by filename



Miner, Jonathan W (CSC) (US SSA) wrote:

------------------------------

Try this to start out...

#!/bin/sh

last_seq_number=UNKNOWN

for f in `ls XXXX*bz2`; do
seq_number=`echo $f | cut -d'_' -f4 | cut -d'.' -f1`

if [ $last_seq_number != 'UNKNOWN' ]; then
diff=`expr $seq_number - $last_seq_number`
if [ $diff -ne 1 ]; then
echo "Missing Files"
fi
fi

last_seq_number=$seq_number
done



Man that is really close. However, and the one thing I neglected was that the filenames have different names before the last 2 digits:

XXXX20070515_112011_942_10.bz2 and in the same directory there may be:
XXXX20070515_112011_943_10.bz2

I'm not interested in the _###_ values, just the last 2 digits. Is there a way to build that in?


--
Recedite, plebes! Gero rem imperialem!


Mark Haney
Sr. Systems Administrator
ERC Broadband
(828) 350-2415

Call (866) ERC-7110 for after hours support

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages