From owner-freebsd-questions@FreeBSD.ORG Fri Nov 9 12:41:19 2007 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 458D416A41B for ; Fri, 9 Nov 2007 12:41:19 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from mailout.zetnet.co.uk (mailout.zetnet.co.uk [194.247.47.231]) by mx1.freebsd.org (Postfix) with ESMTP id E7B6F13C4B6 for ; Fri, 9 Nov 2007 12:41:18 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from irwell.zetnet.co.uk ([194.247.47.48] helo=zetnet.co.uk) by mailout.zetnet.co.uk with esmtp (Exim 4.50) id 1IqTAY-0005JQ-EB for questions@freebsd.org; Fri, 09 Nov 2007 12:41:06 +0000 Received: from esperance.zetnet.co.uk (54-144.adsl.zetnet.co.uk [194.247.54.144]) by zetnet.co.uk (8.14.1/8.14.1/Debian-9) with SMTP id lA9Cf5ar008611 for ; Fri, 9 Nov 2007 12:41:06 GMT Received: (qmail 35979 invoked by uid 1001); 9 Nov 2007 12:41:00 -0000 From: "Frank Shute" Date: Fri, 9 Nov 2007 12:41:00 +0000 To: =?iso-8859-1?Q?Sd=E4vtaker?= Message-ID: <20071109124100.GA22571@melon.esperance-linux.co.uk> References: <4733CAB4.2080508@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4733CAB4.2080508@gmail.com> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 6.2-STABLE i386 X-Organisation: 'Esperance Linux' Cc: questions@freebsd.org Subject: Re: problems using ls with for_in (SH) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Frank Shute List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Nov 2007 12:41:19 -0000 On Thu, Nov 08, 2007 at 11:49:24PM -0300, Sdvtaker wrote: > > Im trying to get a file with all the md5 hashes of one directory. > My initial script was this: > #!/bin/sh > for file in $(ls) > do > echo $file > md5 $file > done > > The problem is with the file names who contains "whitespaces" becouse > the for_in passed each word as one iteration and not the full filename, > I'd tried using -B in ls, but doesnt help. > Any idea what can i do? > Thanks! > Sdäv You could use "find" which avoids the subdirs: find . -maxdepth 1 -type f -print -exec md5 {} \; -- Frank Contact info: http://www.esperance-linux.co.uk/misc/contact.html