[ILUG] Shell substitute regexp

Jerry Walsh jerry at aardvark.ie
Tue Jul 24 11:57:23 IST 2001


At 11:42 24/07/01 +0100, Kenn Humborg wrote:
> > #!/bin/sh
> > find -maxdepth 1 -type f -name "*.*" |
> > sed -e 's/\(.*\)\.\(.*\)/"\1\.\2" "\1"/' |
> > xargs -r -n2 mv
>
>Bleargh...  basename(1), my friend, basename(1):
>
>    for i in *.dat ; do mv $i `basename $i .dat` ; done

Why are you using find anyway? why not just ls *.dat ?

Watch that *.* glob too,

Jerry.






More information about the ILUG mailing list