Date: Fri, 9 Nov 2007 12:41:00 +0000 From: "Frank Shute" <frank@esperance-linux.co.uk> To: =?iso-8859-1?Q?Sd=E4vtaker?= <sdavtaker@gmail.com> Cc: questions@freebsd.org Subject: Re: problems using ls with for_in (SH) Message-ID: <20071109124100.GA22571@melon.esperance-linux.co.uk> In-Reply-To: <4733CAB4.2080508@gmail.com> References: <4733CAB4.2080508@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071109124100.GA22571>