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

Re: OT: Alternatives to ls for sorting files by modification time



Hi Miquel!

Thanks a lot for your quick reply!

On Wed, 25 Sep 2002, Miquel van Smoorenburg wrote:

> [...] 
> No, you probably have lots of filed in $BACKUP_DIR/arc, so
> the expression $BACKUP_DIR/arc/*.arc expands in more arguments
> than is possible on the command line of ls.

Right, I do have a lot of files in $BACKUP_DIR/arc and *all* of them end
in ".arc", so I guess I could just do without "*.arc".

> 
> How about
> 
> FILES=`$LS -t1 $BACKUP_DIR/arc | grep '\.arc$' | $TAIL -$NUM_OF_FILES`
> 
> This way, you let ls list all files, and filter the arc files
> out with grep (note I left out '-l' which seems unnessecary)

Yes, you are right, the "-l" is not required. Probably I can omit the grep
if all my files end in ".arc", right?

> If _that_ list gets too long you can always do
> 
> $LS -t1 $BACKUP_DIR/arc | grep '\.arc$' | $TAIL -$NUM_OF_FILES |
> while read i
> do
>   $RM -f $i
> done

Thanks a lot for your suggestions, I will try them out!

Greetings,

	Holger



Reply to: