From owner-freebsd-questions@FreeBSD.ORG Fri Oct 14 17:49:32 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1C0C016A41F for ; Fri, 14 Oct 2005 17:49:32 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from relay04.roc.ny.frontiernet.net (relay04.roc.ny.frontiernet.net [66.133.182.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id 74B1443D60 for ; Fri, 14 Oct 2005 17:49:31 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from filter07.roc.ny.frontiernet.net (filter07.roc.ny.frontiernet.net [66.133.183.74]) by relay04.roc.ny.frontiernet.net (Postfix) with ESMTP id A1C33358B15; Fri, 14 Oct 2005 17:49:30 +0000 (UTC) Received: from relay04.roc.ny.frontiernet.net ([66.133.182.167]) by filter07.roc.ny.frontiernet.net (filter07.roc.ny.frontiernet.net [66.133.183.74]) (amavisd-new, port 10024) with LMTP id 16257-08-14; Fri, 14 Oct 2005 17:49:30 +0000 (UTC) Received: from blacklamb.mykitchentable.net (67-51-164-214.dsl1.elk.ca.frontiernet.net [67.51.164.214]) by relay04.roc.ny.frontiernet.net (Postfix) with ESMTP id 06168358CCF; Fri, 14 Oct 2005 17:49:13 +0000 (UTC) Received: from [165.107.42.123] (unknown [165.107.42.123]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by blacklamb.mykitchentable.net (Postfix) with ESMTP id 4DC331549FC; Fri, 14 Oct 2005 10:49:11 -0700 (PDT) Message-ID: <434FEF24.4050803@mykitchentable.net> Date: Fri, 14 Oct 2005 10:47:16 -0700 From: Drew Tomlinson User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Paul Schmehl References: <434EE80D.2010103@mykitchentable.net> <0D55CDDCD0D6445B3FF1FA6B@Paul-Schmehls-Computer.local> <434FD118.60109@mykitchentable.net> <72CE9870C77DFB8443C76023@utd59514.utdallas.edu> In-Reply-To: <72CE9870C77DFB8443C76023@utd59514.utdallas.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-2.3.2 (20050629) at filter07.roc.ny.frontiernet.net Cc: FreeBSD Questions Subject: Re: sh Scripting - String Manipulation X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2005 17:49:32 -0000 On 10/14/2005 9:27 AM Paul Schmehl wrote: > --On Friday, October 14, 2005 08:39:04 -0700 Drew Tomlinson > 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