Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Oct 2005 10:47:16 -0700
From:      Drew Tomlinson <drew@mykitchentable.net>
To:        Paul Schmehl <pauls@utdallas.edu>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: sh Scripting - String Manipulation
Message-ID:  <434FEF24.4050803@mykitchentable.net>
In-Reply-To: <72CE9870C77DFB8443C76023@utd59514.utdallas.edu>
References:  <434EE80D.2010103@mykitchentable.net>	<0D55CDDCD0D6445B3FF1FA6B@Paul-Schmehls-Computer.local>	<434FD118.60109@mykitchentable.net> <72CE9870C77DFB8443C76023@utd59514.utdallas.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 10/14/2005 9:27 AM Paul Schmehl wrote:

> --On Friday, October 14, 2005 08:39:04 -0700 Drew Tomlinson 
> <drew@mykitchentable.net> wrote:
>
>>
>>
>> That's a good idea (and something else I never thought of) if I wanted
>> all the files, not just the *.jpg files.  And as I'll explain below, I
>> intend to expand this script to work with additional directories where I
>> might just want the *.mp3 or the just the *.avi, *.mpg, etc.  My thought
>> was to build a script and run it through cron to keep the symlinks
>> updated.
>>
> OK.  Then I think you're going about it the wrong way.
>
> This would accomplish what you want without having to do any string 
> manipulation, and without having to generate a list of files.  The for 
> loop does all that for you.
>
> 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?

Thanks again,

Drew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?434FEF24.4050803>