problems using ls with for_in (SH)
jhary at unsane.co.uk
Fri Nov 9 03:10:28 PST 2007
> Im trying to get a file with all the md5 hashes of one directory.
> My initial script was this:
> for file in $(ls)
> echo $file
> md5 $file
> 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?
Use Quoting ?
(jhary at prawn)$ls
another file with spaces file with space no-spaces-here
(jhary at 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
MD5 (no-spaces-here) = aaac9a687bd4ea9d2fc487e9cfb345f7
works for me.
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions