RE: Sort files by filename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





-----Original Message-----
From:	fedora-list-bounces@xxxxxxxxxx on behalf of Mark Haney
Sent:	Tue 07/31/2007 10:52 AM
To:	For users of Fedora
Cc:	
Subject:	Sort files by filename

This is really a general linux question. I have a series of files in a 
format like this:

XXXX20070515_112011_942_10.bz2
XXXX20070515_112011_942_12.bz2 etc,

and I am trying to find a way to do 2 things, one, sort these files in 
order, and then once in order, find the files that are numerically 
missing based on the last 2 numbers in the file name.  So if I have (as 
above I want to know that file XXXX20070515_112011_942_11.bz2 is 
missing.  Can someone get me started on this, I'm stumped.
------------------------------

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

<<winmail.dat>>

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux