[ILUG] Shell substitute regexp

Padraig Brady Padraig at AnteFacto.com
Tue Jul 24 11:47:48 IST 2001


Doh!
And I was just using basename yeaterday!
Actually I noticed dirname yesterday which I
never new about.

Padraig.

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:
> 
>>How about:
>>
>>#!/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
> 
> Later,
> Kenn






More information about the ILUG mailing list