in reply to Unix - Keep the last modified file in the directory and move/copy the rest of the files.
maybe you should try and do it using something you're familiar with. in this case i would probably just use a simple shell script.
#!/bin/sh ls -t $1 | ( read keepthisone while read movethisone do echo $2 $movethisone $3 done )
very simple, serves multiple purposes.
$ ls -1 whacl-* whacl-20030601223002.gz whacl-20030602223002.gz whacl-20030603223003.gz whacl-20030604223003.gz whacl-20030605223003.gz $ ./movem.sh 'whacl-*' whacl-20030604223003.gz whacl-20030603223003.gz whacl-20030602223002.gz whacl-20030601223002.gz $ ./movem.sh 'whacl-*' cp /dev/null cp whacl-20030604223003.gz /dev/null cp whacl-20030603223003.gz /dev/null cp whacl-20030602223002.gz /dev/null cp whacl-20030601223002.gz /dev/null $ ./movem.sh 'whacl-*' mv /path/to/foreverstore mv whacl-20030604223003.gz /path/to/foreverstore mv whacl-20030603223003.gz /path/to/foreverstore mv whacl-20030602223002.gz /path/to/foreverstore mv whacl-20030601223002.gz /path/to/foreverstore $ ./movem.sh 'whacl-*' rm rm whacl-20030604223003.gz rm whacl-20030603223003.gz rm whacl-20030602223002.gz rm whacl-20030601223002.gz $ ./movem.sh 'whacl-*' rm | sh $ ls whacl-* whacl-20030605223003.gz
take out the 'echo' if you don't want to check your commands before doing them.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Unix - Keep the last modified file in the directory and move/copy the rest of the files.
by hyliau (Initiate) on Jun 09, 2003 at 05:41 UTC | |
by zengargoyle (Deacon) on Jun 09, 2003 at 07:23 UTC | |
by hyliau (Initiate) on Jun 09, 2003 at 07:50 UTC | |
by zengargoyle (Deacon) on Jun 09, 2003 at 08:12 UTC | |
by hyliau (Initiate) on Jun 09, 2003 at 08:41 UTC | |
|