From owner-freebsd-questions@FreeBSD.ORG Fri Nov 9 11:10:28 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 ADE3C16A420 for ; Fri, 9 Nov 2007 11:10:28 +0000 (UTC) (envelope-from jhary@unsane.co.uk) Received: from unsane.co.uk (unsane-pt.tunnel.tserv2.fmt.ipv6.he.net [IPv6:2001:470:1f03:1f1::2]) by mx1.freebsd.org (Postfix) with ESMTP id 13EF013C4BD for ; Fri, 9 Nov 2007 11:10:27 +0000 (UTC) (envelope-from jhary@unsane.co.uk) Received: from prawn.unsane.co.uk (150.117-84-212.staticip.namesco.net [212.84.117.150]) (authenticated bits=0) by unsane.co.uk (8.14.0/8.14.0) with ESMTP id lA9BAMQY037949 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 9 Nov 2007 11:10:24 GMT (envelope-from jhary@unsane.co.uk) Message-ID: <4734401C.4040508@unsane.co.uk> Date: Fri, 09 Nov 2007 11:10:20 +0000 From: Vince User-Agent: Thunderbird 2.0.0.6 (X11/20071101) MIME-Version: 1.0 To: =?ISO-8859-1?Q?Sd=E4vtaker?= References: <4733CAB4.2080508@gmail.com> In-Reply-To: <4733CAB4.2080508@gmail.com> X-Enigmail-Version: 0.95.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 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 List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Nov 2007 11:10:28 -0000 Sdävtaker 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 > Use Quoting ? (jhary@prawn)$ls another file with spaces file with space no-spaces-here [11:08:54:/usr/home/jhary/tmp/spacetmp] (jhary@prawn)$for file in * ; do echo "$file" ; md5 "$file" ; done another file with spaces MD5 (another file with spaces) = 40393f6dba09f89ef5cf32c3aec61f32 file with space MD5 (file with space) = 1de1a1be1433df2d7af11d839db3b0c1 no-spaces-here MD5 (no-spaces-here) = aaac9a687bd4ea9d2fc487e9cfb345f7 works for me. Vince > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org"