From owner-freebsd-questions@FreeBSD.ORG Fri Oct 14 23:31:46 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 5DFD716A41F for ; Fri, 14 Oct 2005 23:31:46 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.93]) by mx1.FreeBSD.org (Postfix) with ESMTP id 92A4343D45 for ; Fri, 14 Oct 2005 23:31:44 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from flame.pc (patr530-a162.otenet.gr [212.205.215.162]) by aiolos.otenet.gr (8.13.4/8.13.4/Debian-1) with ESMTP id j9ENVNoJ019735; Sat, 15 Oct 2005 02:31:35 +0300 Received: from flame.pc (flame [127.0.0.1]) by flame.pc (8.13.4/8.13.4) with ESMTP id j9ENTtV1049315; Sat, 15 Oct 2005 02:29:55 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by flame.pc (8.13.4/8.13.4/Submit) id j9ENTGES049310; Sat, 15 Oct 2005 02:29:16 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Sat, 15 Oct 2005 02:29:16 +0300 From: Giorgos Keramidas To: Drew Tomlinson Message-ID: <20051014232916.GA49272@flame.pc> References: <434EE80D.2010103@mykitchentable.net> <0D55CDDCD0D6445B3FF1FA6B@Paul-Schmehls-Computer.local> <434FD118.60109@mykitchentable.net> <72CE9870C77DFB8443C76023@utd59514.utdallas.edu> <434FEF24.4050803@mykitchentable.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <434FEF24.4050803@mykitchentable.net> Cc: Paul Schmehl , freebsd-questions@freebsd.org 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 23:31:46 -0000 On 2005-10-14 10:47, Drew Tomlinson 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