sh Scripting - String Manipulation
Giorgos Keramidas
keramida at ceid.upatras.gr
Fri Oct 14 16:31:46 PDT 2005
On 2005-10-14 10:47, Drew Tomlinson <drew at mykitchentable.net> wrote:
> On 10/14/2005 9:27 AM Paul Schmehl wrote:
> >for files in /my/dir/for/files/*.jpg
> >do
> >NEWFILES=`$files | cut -d'/' -f 6`
> >ln -s $files /new/dir/for/pics/$NEWFILES
> >done
>
> But there is still one problem. This won't search recursively which is
> why I was using find. However if I start with
>
> "for files in `find /multimedia -iname "*.jpg" -print"
>
> this would probably work. I'll try it and see. Or is there some
> other (better) way to search for files recursively?
find(1) is usually nice. One thing you may want to be careful about
with find in a for loop is that filenames with whitespace are probably
going to end up in a huge mess. It may be better to use something like
the following:
find /multimedia -iname '*.jpg' | \
while read fname ;do
# Manipulate ${fname}
done
More information about the freebsd-questions
mailing list