sh Scripting - String Manipulation

Paul Schmehl pauls at utdallas.edu
Thu Oct 13 21:04:27 PDT 2005


--On October 13, 2005 4:04:45 PM -0700 Drew Tomlinson 
<drew at mykitchentable.net> wrote:

> I'm working on a script that reads a directory using 'find' and its
> '-exec' primary to create a symlink to the file.  So for example, I have
> the following command:
>
find /multimedia/Pictures -iname "*.jpg" -print | cut -d'/' -f4

You'll have to play with the field value (-f) to get the right location, 
but this would return only the filename.
>
> This command returns a bunch of filenames.  Here's an example of one:
>
> /multimedia/Pictures/2005 Kimberly & Rich/IMG_1210.JPG
>
> What I'd like to is get '-exec' to run this command:
>
I don't understand what you're trying to do here.

> ln -s "/multimedia/Pictures/2005 Kimberly & Rich/IMG_1210.JPG" "2005
> Kimberly & Rich/IMG_1210.JPG"
>
Are you trying to create symlinks in a different directory?  If so, why not 
do this?

ln -s dir1/ dir2/

Then, when you add new files to dir1/ they will automatically show up in 
dir2/ because the dir is symlinked rather than the individual files.

What exactly are you trying to accomplish?

Paul Schmehl (pauls at utdallas.edu)
Adjunct Information Security Officer
University of Texas at Dallas
AVIEN Founding Member
http://www.utdallas.edu/


More information about the freebsd-questions mailing list