Re: problems using ls with for_in (SH)
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 ? ([EMAIL PROTECTED])$ls another file with spaces file with space no-spaces-here [11:08:54:/usr/home/jhary/tmp/spacetmp] ([EMAIL PROTECTED])$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 [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: problems using ls with for_in (SH)
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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
problems using ls with for_in (SH)
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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
problems using ls with for_in (SH)
=?ISO-8859-1?Q?Sd=E4vtaker?= writes: 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? Yes.:-) Find the documetation, and look up the IFS environment variable. Robert Huff ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: problems using ls with for_in (SH)
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 [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]