[NCLUG] shell scripting

Michael Dwyer mdwyer at sixthdimension.com
Thu Sep 13 11:55:58 MDT 2001


> * Michael Dwyer (mdwyer at sixthdimension.com) [010913 11:25]:
> > >   i have what i believe is a simple shell scripting question. i
have a
> > > number of files in a directory. some of them have been modified
today.
> > i
> > > want to copy the files that have been modified today to another
> > directory.
> > >
> > > something like
> > >
> > >  for ($i in <modified today>) cp $i /some/directory
> >
> > I think find(1) is what you are looking for.  I'm not all that
> > familiar with find, but the man page is pretty good.  You'll
> > probably want something like this:
> >
> > cp ` find -moddate TODAY ` /some/directory
> >    ^----  Backticks  ----^
> >
>
> Backticks have been deprecated in all but the oldest of bourne shell
> derivatives for years.  Try to start using the $( ) construct.  They
> nest, are far more readable and are part of the POSIX spec.

Bah!  All you kids and your new-fangled constructs...  Back in the war,
we used backticks to conserve INK for propaganda posters!

Anyway, a remarkably fast and educational response from all!  I'm
always amazed at how many different ways to do things.  I'm sort
of suprised nobody offered up a chunk of PERL to do it...

Can you give a quick lesson on the $( ) construct, though?  I tried
sort $(ls) and ... uh... it looks like it tried to sort the binary.





More information about the NCLUG mailing list