[ Date Index ][
Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]
Jon, Try the following: #!/bin/bash find . -type f -name '*' |while read -r AFILE do NEWNAME=`expr "$AFILE" : "\(.*\)?"` if [ -a $NEWNAME ] then echo Duplicate file name $NEWNAME would be created else mv $AFILE $NEWNAME fi done Note the 'for' loop is replaced by a while using read. Changle the twinkle (*) in the find statement to the pattern you require (but don't forget to quote it!). Cheers, Clive -----Original Message----- From: Jonathan Melhuish [mailto:jon@xxxxxxxxxxxxxxxx] Sent: 25 June 2003 17:46 To: list@xxxxxxxxxxxx Subject: Re: [LUG] I'm back :-) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 25 June 2003 17:24, Jonathan Melhuish wrote: > Oops, it was all my fault (suprise, suprise). I changed "for AFILE in > *\?*" to "for AFILE in ./*" because I just wanted to run it against every > file. Thus, it would seem, completely screwing everything up... Okay, one last quickie, if anyone's still feeling in a generous mood ;-) How do I make it recurse through subdirectories? Do I pipe it the output of find or something? Cheers, Jon -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE++dG1eTVvFHAhe5cRAjPvAJkB/VBK3diAmaQNJUwyEt39ff6dyACgi6Gj 3ra9Fp/dxy7BOTIcWX8RNlY= =2/su -----END PGP SIGNATURE----- -- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe. ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ -- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe.