Date: Fri, 14 Oct 2005 11:27:46 -0500 From: Paul Schmehl <pauls@utdallas.edu> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: sh Scripting - String Manipulation Message-ID: <72CE9870C77DFB8443C76023@utd59514.utdallas.edu> In-Reply-To: <434FD118.60109@mykitchentable.net> References: <434EE80D.2010103@mykitchentable.net> <0D55CDDCD0D6445B3FF1FA6B@Paul-Schmehls-Computer.local> <434FD118.60109@mykitchentable.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 Before you put the symlink line in the script, you'll want to echo $NEWFILES so you can make sure you're cutting at the right place. (Practice on the commandline so you can see what cut is doing.) Paul Schmehl (pauls@utdallas.edu) Adjunct Information Security Officer University of Texas at Dallas AVIEN Founding Member http://www.utdallas.edu/ir/security/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?72CE9870C77DFB8443C76023>