in reply to Re: Re: Unix - Keep the last modified file in the directory and move/copy the rest of the files.
in thread Unix - Keep the last modified file in the directory and move/copy the rest of the files.
1. $1 , $2 , $3 - what should this variable use for? when to use it? is this a parameter to be pass in when we run the ./movem.sh?
yes, they are the parameters, pretend i gave them names.
2. keepthisone - what should this variable use for? when to use it? is this a parameter to be pass in when we run the ./movem.sh? or I need to put in the value here?
pretend i called this variable 'the_most_recent_file'.
3. movethisone - what should this variable use for? when to use it? is this a parameter to be pass in when we run the ./movem.sh? or I need to put in the value here?
pretend i called this variable 'not_the_most_recent_file'
#!/bin/sh files_to_check=$1 command_to_run=$2 the_destination=$3 echo "# looking for files matching $files_to_check" # ls -t sorts files by last modification time, most recent to oldest ls -t $files_to_check | ( # the first line will be the most recent file read the_most_recent_file echo "# do nothing with the most recent file: $the_most_recent_file" # the rest of the lines will not be the most recent file echo "# do something with the rest of the files" while read not_the_most_recent_file do echo $command_to_run $not_the_most_recent_file $the_destination done )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: 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 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 | |
by zengargoyle (Deacon) on Jun 09, 2003 at 23:04 UTC | |
by hyliau (Initiate) on Jun 10, 2003 at 07:10 UTC |