-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks Malc, I will try that on Monday.
Malcolm Hunter wrote: >> As posted on Linux Format User Forums: >> >> Basically I was experimenting in shell script and was trying to create a >> useful script that took each file in the current directory (*.sh) and for >> each file, create a MD5 hash and save that hash in a file of the same name >> as the file (appended with a .md5 extension), so the basic script looked >> something like this: >> >> *Code:* >> FILES="*.sh" >> for f in $FILES >> do >> md5sum $f > $f.md5 >> done >> >> >> Now, what is annoying is I have just run this at home on ubuntu (debian) >> and >> it has done the job as expected, however when I ran this on a test box at >> work today running CentOS (RedHat) it kept putting ALL the MD5 hashes in >> one >> file called "*.sh.md5", whereas what I was expecting, and what I got on >> Ubuntu, was say I had some files like so: >> >> *Code:* >> shellscript1.sh >> shellscript2.sh >> >> >> after I run my script above in the current directory, and then run an "ls" >> I >> should get: >> >> *Code:* >> shellscript1.sh >> shellscript1.sh.md5 >> shellscript2.sh >> shellscript2.sh.md5 >> >> >> Can anyone explain this deviant behaviour on Red Hat and give any tips >> that >> would allow the shellscript to work on either platform? >> >> Oh yes and if the code above is of any use you are welcome to it, and >> modify/redistribute as you see fit. It was a test really as I am learning >> "loops" at the moment and wondered if I could write a script that works >> with >> each file in a given folder. > > Using "*" gives unpredictable results depending on the context. Better to use > the output of a command: > > LIST=`ls *.sh` > > Cheers, > Malc > - -- ***** Richard Forth Great Natural Health and wellbeing products http://www.aloevera-crowland.co.uk/ ================================ Do you want to work from home? Part-Time? Running your own business? Call me now to find out about opportunities in your area 07870 897755. ================================ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAksRppwACgkQQ6xgmxzOp8nVMwCZAclLYq/a7vRzDVgLuskPdoyj UXYAn2sdOBmtKBckkaKGbIv6ROOfBYHf =2mD7 -----END PGP SIGNATURE----- _______________________________________________ Peterboro mailing list [email protected] https://mailman.lug.org.uk/mailman/listinfo/peterboro
