From owner-freebsd-questions@FreeBSD.ORG Wed Aug 5 16:32:48 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F08621065701 for ; Wed, 5 Aug 2009 16:32:48 +0000 (UTC) (envelope-from mel.flynn+fbsd.questions@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id BCD818FC0A for ; Wed, 5 Aug 2009 16:32:48 +0000 (UTC) (envelope-from mel.flynn+fbsd.questions@mailing.thruhere.net) Received: from smoochies.rachie.is-a-geek.net (mailhub.lan.rachie.is-a-geek.net [192.168.2.11]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id 0CB647E818 for ; Wed, 5 Aug 2009 08:32:48 -0800 (AKDT) From: Mel Flynn To: freebsd-questions@freebsd.org Date: Wed, 5 Aug 2009 08:32:47 -0800 User-Agent: KMail/1.11.4 (FreeBSD/8.0-BETA2; KDE/4.2.4; i386; ; ) References: <42D44C8E-1E22-426C-A9AA-0FBF2A52188A@socket.net> <200908050712.39131.mel.flynn+fbsd.questions@mailing.thruhere.net> <4ad871310908050833k54f3f3a7v679737941e3fa235@mail.gmail.com> In-Reply-To: <4ad871310908050833k54f3f3a7v679737941e3fa235@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200908050832.47299.mel.flynn+fbsd.questions@mailing.thruhere.net> Subject: Re: find question 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: Wed, 05 Aug 2009 16:32:49 -0000 On Wednesday 05 August 2009 07:33:42 Glen Barber wrote: > On Wed, Aug 5, 2009 at 11:12 AM, Mel > > Flynn wrote: > > On Wednesday 05 August 2009 07:00:40 Glen Barber wrote: > >> On Wed, Aug 5, 2009 at 3:36 AM, Matthew > >> > >> Seaman wrote: > >> > Try this as: > >> > > >> > for line in $( cat $FILELIST ) ; do > >> > echo $line > >> > find $line -type f >> $TMPFILE > >> > done > >> > > >> > *assuming that none of the directory names in $FILELIST contain > >> > spaces* > >> > >> for line in $( cat $FILELIST | sed -e 's/\ //g') ; do > >> echo $line > >> find $line -type f >> $TMPFILE > >> done > >> > >> This *should* fix any directories containing spaces. > > > > And also make find look in non-existing directories. > > True, but any script that needs to find directories containing spaces > is going to be hack-ish. > > for line in $( cat $FILELIST | sed -e 's/\ /SPACE/g') ; do > echo $line | sed -e 's/SPACE/\ /g' > find $line -type f >> $TMPFILE > done Not really, simply quote your arguments so that IFS is not in the picture. The OP had the right the idea by using a pipe+while read. % echo My Documents|while read LINE; do find "${LINE}" -type f; done My Documents/foo -- Mel