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

2002-09-26 Thread Adrian von Bidder
On Thu, 2002-09-26 at 19:26, Jeff Cours wrote: > Adrian von Bidder wrote: > > Thanks a lot. Will try. I don't speak perl fluently, that's why I looked > > for a shell script - but it gets the job done, and perl is installed by > > default, so it doesn't matter. > > Glad to help! One thing to be a

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

2002-09-26 Thread Jeff Cours
Adrian von Bidder wrote: > Thanks a lot. Will try. I don't speak perl fluently, that's why I looked > for a shell script - but it gets the job done, and perl is installed by > default, so it doesn't matter. Glad to help! One thing to be aware of is that the script is currently set up to use file

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

2002-09-26 Thread Bob Proulx
Vineet Kumar <[EMAIL PROTECTED]> [2002-09-25 11:01:35 -0700]: > /usr/bin/find $BACKUP_DIR/arc -type f -maxdepth 1 -name \*.arc \ > -mtime +30 -exec rm \{\} \; A very, very small point with your good note. I strongly advise avoiding the hard code of the /usr/bin/find path. This has always come b

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

2002-09-26 Thread Holger Rauch
Hi! Thanks to all who responded to my question(s)! It's working now. I use the suggestion made by Miquel, as shown below, though I will be happy to try the others as well. I've got some scripting tricks to play with now :-) (The reason I was using this method is that it integrates well in my pre

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

2002-09-25 Thread Adrian von Bidder
On Wed, 2002-09-25 at 19:47, Jeff Cours wrote: > > If somebody wants to do some clever scripting: I have a similar need, > > but not yet found a simple solution: I want to purge some cache > > directory and just leave the most recently accessed k megabytes. File > > sizes vary greatly, so file co

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

2002-09-25 Thread Vineet Kumar
* Holger Rauch ([EMAIL PROTECTED]) [020925 01:07]: > > [...] > > processing the list, i.e. with xargs? It's hard to make suggestions > > without seeing what you're trying to do... > > You're right ;-) What I'm doing is > > FILES=`$LS -lt1 $BACKUP_DIR/arc/*.arc | $TAIL -$NUM_OF_FILES` > for i in

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

2002-09-25 Thread Jeff Cours
Adrian von Bidder wrote: > find "$BACKUP_DIR/arc" -name '*.arc' -printf '%A@:%p\n' \ > | sort -g -t : \ > | cut -d : -f 2- \ > | head -n "$NUM_OF_FILES" \ > | xargs -r rm -f > Another option might be to re-cast the problem a bit. If you're just trying to keep the number

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

2002-09-25 Thread Shaya Potter
stat or write a program arround stat(). spotter@zaphod:~$ stat cd-door.c File: `cd-door.c' Size: 778 Blocks: 8 IO Block: 4096 Regular File Device: 302h/770d Inode: 1254382 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ spotter) Gid: ( 1000/ spotter) A

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

2002-09-25 Thread Holger Rauch
Hi Tom! Thanks again for your quick reply! On Wed, 25 Sep 2002, Tom Cook wrote: > [...] > I can safely say that I knew nothing about the -1 option to ls when I > sent that message, except that I have observed this result: > > tkcook@brain:~/mbox$ ls -lt1 > total 40 > drwx--S---2 tkcook

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

2002-09-25 Thread Tom Cook
On 0, Holger Rauch <[EMAIL PROTECTED]> wrote: > Hi Tom! > > Thanks for your quick reply! > > On Wed, 25 Sep 2002, Tom Cook wrote: > > > [...] > > All I can say is... it works for me. How many files in the directory > > where you're having this fail? It works for me in /usr/lib. > > > > # ls

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

2002-09-25 Thread Holger Rauch
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

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

2002-09-25 Thread Adrian von Bidder
On Wed, 2002-09-25 at 10:07, Holger Rauch wrote: > Hi Vineet! > > Thanks a lot for your quick reply! > > On Wed, 25 Sep 2002, Vineet Kumar wrote: > > > [...] > > processing the list, i.e. with xargs? It's hard to make suggestions > > without seeing what you're trying to do... > > You're right

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

2002-09-25 Thread Holger Rauch
Hi Tom! Thanks for your quick reply! On Wed, 25 Sep 2002, Tom Cook wrote: > [...] > All I can say is... it works for me. How many files in the directory > where you're having this fail? It works for me in /usr/lib. > > # ls /usr/lib -lt1 | wc -l > 841 I suspect the problem is not $NUM_OF_

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

2002-09-25 Thread Miquel van Smoorenburg
In article <[EMAIL PROTECTED]>, Holger Rauch <[EMAIL PROTECTED]> wrote: >You're right ;-) What I'm doing is > >FILES=`$LS -lt1 $BACKUP_DIR/arc/*.arc | $TAIL -$NUM_OF_FILES` >for i in $FILES; do > $RM -f $i >done > >($LS contains the path to "ls" and $TAIL the path to "tail") > >I want to remove

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

2002-09-25 Thread Tom Cook
On 0, Holger Rauch <[EMAIL PROTECTED]> wrote: > Hi Vineet! > > Thanks a lot for your quick reply! > > On Wed, 25 Sep 2002, Vineet Kumar wrote: > > > [...] > > processing the list, i.e. with xargs? It's hard to make suggestions > > without seeing what you're trying to do... > > You're right ;

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

2002-09-25 Thread Holger Rauch
Hi Vineet! Thanks a lot for your quick reply! On Wed, 25 Sep 2002, Vineet Kumar wrote: > [...] > processing the list, i.e. with xargs? It's hard to make suggestions > without seeing what you're trying to do... You're right ;-) What I'm doing is FILES=`$LS -lt1 $BACKUP_DIR/arc/*.arc | $TAIL -

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

2002-09-25 Thread Vineet Kumar
* Holger Rauch ([EMAIL PROTECTED]) [020925 00:47]: > Hi! > > I admit that this is off-topic since it's a general shell scripting > question, but what alternative commands instead of ls can be used to sort > files by modification time? I'm not interested in the modification times, > just the file

OT: Alternatives to ls for sorting files by modification time

2002-09-25 Thread Holger Rauch
Hi! I admit that this is off-topic since it's a general shell scripting question, but what alternative commands instead of ls can be used to sort files by modification time? I'm not interested in the modification times, just the file names. So, actually in something that emulates "ls -lt1" behavi