Recent Files and Creating Symbolic Links

Charles Steinkuehler charles at steinkuehler.net
Mon Mar 7 06:13:16 CST 2005


Jon Moss wrote:

> Thanks for both suggestions.  I will try both of them.
> 
> Have a great week!

Another option for you.  I don't grok perl well, and find the syntax for the 
find command difficult to remember (and complex to properly escape at the 
command line).  For a simple task like yours, I'd fall back to one of my 
shell script standbys: using "while read ..." to loop over every line of 
input.  You can either do this inline, with pipe symbols, or as a seperate 
command using a text file to store the intermediate results (and allow for 
visual verification/editing).

Just type the following at the command line

while read VALUE ; do
# Put your commands here
echo $VALUE
done < my.text.file

NOTES:

You don't have to type everything on one line...once you type the 'while', 
the shell interpreter knows the command isn't finished until you type 'done' 
and keeps giving you new prompts.

You can also easily do the same thing with piped command output, ie:

find /path/to/photos -mtime 48 -name '*.jpg' | while read FILE ; do
ln -s $FILE my/directory/$FILE
done

-- 
Charles Steinkuehler
charles at steinkuehler.net


More information about the Kclug mailing list