Sort files by filename

Les Mikesell lesmikesell at gmail.com
Tue Jul 31 20:01:51 UTC 2007


Mark Haney wrote:
>> count=xx
>> for i in $(ls <something>* | sort) ; do
                         ^^^^^^^^^^^^
The |sort isn't necessary since the shell always returns wild-card 
expansions in sorted order.  In fact the ls isn't necessary either since 
the shell has already generated the list.
   for i in something*
will do the same thing.

>>     file_num=$(cut --delimiter=_ -f1 $i)
>>     while [ $count -lt $file_num ] ; do
>>         echo Missing file number $count   
>>         count++
>>     done
>> done
>>

> This is great. I think now I have enough pieces to make something work. 
> I appreciate all the help.

The above doesn't help if you lose the 1st or last bunch of files.  Do 
you always get the same set every day?

-- 
   Les Mikesell
    lesmikesell at gmail.com




More information about the fedora-list mailing list