D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] I'm back :-)



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jonathan Melhuish wrote:
>
> Please?  Pwetty please?

Not tested on directories, and the brave would do the eval in a "find"
command, the clever would do it without creating a subprocess for each expr.

I suspect you can generalise the "for" statement to a find statement
without any major changes if that is needed.

Oh multiple question marks are a pain, but you can always run it more
than once.

Comes with the usual, "you ran what!?" warranty, if it destroys your
files, ends life as we know it on the planet etc I'll refund the
purchase price ;-)

#!/bin/bash
for AFILE in *\?*
do
 NEWNAME=`expr "$AFILE" : "\(.*\)?"`
 if [ -a $NEWNAME ]
 then
    echo Duplicate file name $NEWNAME would be created
 else
     mv $AFILE $NEWNAME
 fi
done
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE++M2NGFXfHI9FVgYRAhaWAJ90DBvJZPp4ZcKqeOwczjppc+ClwQCgz4F1
DlVbkneRQVbWNfu4r7rNl8c=
=peB+
-----END PGP SIGNATURE-----

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly