RE: Sort files by filename

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

 



Am Dienstag, den 31.07.2007, 11:00 -0400 schrieb Miner, Jonathan W (CSC)
(US SSA):
> -----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.

Just an example tip which simply works with a counter, hope helps you.

a) Do you really need the sorting stuff? I didnt mess with that. 

b) the counter:

[rodolfoap] /home/rodolfoap > for n in $(seq 10 40); do touch XXXX20070515_112011_942_${n}.bz2; done
[rodolfoap] /home/rodolfoap > rm XXXX20070515_112011_942_11.bz2 
[rodolfoap] /home/rodolfoap > rm XXXX20070515_112011_942_22.bz2 
[rodolfoap] /home/rodolfoap > rm XXXX20070515_112011_942_33.bz2 
[rodolfoap] /home/rodolfoap > for n in $(seq 10 40); do if [ ! -e *_${n}.bz2 ]; then echo NOT FOUND: $n; fi; done
NOT FOUND: 11
NOT FOUND: 22
NOT FOUND: 33
[rodolfoap] /home/rodolfoap > 

Good luck.
-- 
Rodolfo Alcazar
Responsable red y datos

Deutsche Gesellschaft für
Technische Zusammenarbeit (GTZ) GmbH

Programa de Apoyo a la Gestión Pública Descentralizada y
Lucha Contra La Pobreza - PADEP
Av. Sánchez Lima 2226
La Paz, Bolivia

Tel: +591 22417628 (121)
Fax: +591 22417628 (126)
Web: www.padep.org.bo
Email: rodolfo.alcazar@xxxxxxxxxxxx


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux