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 )

In reply to Re: Re: Re: Unix - Keep the last modified file in the directory and move/copy the rest of the files. by zengargoyle
in thread Unix - Keep the last modified file in the directory and move/copy the rest of the files. by hyliau

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.