[ILUG] Shell substitute regexp
Padraig at AnteFacto.com
Tue Jul 24 11:47:48 IST 2001
And I was just using basename yeaterday!
Actually I noticed dirname yesterday which I
never new about.
Kenn Humborg wrote:
>>Gavin McCullagh wrote:
>>>This is showing my ignorance, but very quickly..
>>>if I have 10 files called 1.dat .. 10.dat
>>>and I want to do
>>> mv 1.dat 1
>>> mv 10.dat 10
> Padraig wrote:
>>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
More information about the ILUG