Date: Thu, 8 Nov 2007 22:15:40 -0600 From: Dan Nelson <dnelson@allantgroup.com> To: =?utf-8?Q?Sd=C3=A4vtaker?= <sdavtaker@gmail.com> Cc: questions@freebsd.org Subject: Re: problems using ls with for_in (SH) Message-ID: <20071109041540.GB72824@dan.emsphone.com> In-Reply-To: <4733CAB4.2080508@gmail.com> References: <4733CAB4.2080508@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Nov 08), Sdvtaker said: > 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. There's no need to call ls at all. The shell can expand wildcards just fine by itself: for file in * do echo $file md5 $file done but in your case, since md5 can take multiple filenames on its commandline and prints the filename in its output: md5 * will suffice. -- Dan Nelson dnelson@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071109041540.GB72824>