[ALUG] Problem with 'find' and 'basename'
Chris G
cl at isbd.net
Fri Jun 8 12:24:04 BST 2007
I'm trying to change the suffix of all files in a directory hierarchy.
Trying to diagnose my problem I have run the following command:-
find info -name '*.txt' -exec echo `basename {} .txt` \;
A section of the output from the above command is as follows:-
info/motorbikes/zzr1200service.txt
info/motorbikes/luggage.txt
info/motorbikes/index.txt
info/motorbikes/restindex.txt
info/motorbikes/zzr1200info.txt
info/motorbikes/lifts.txt
info/index.txt
info/test/test1.txt
info/test/test2.txt
info/test/test3.txt
So the `basename {} .txt` is doing nothing at all, why?
Looking further it seems as if the `` inside the find are causing the
problem as:-
find info -name '*.txt' -exec basename {} .txt \;
produces the expected output:-
zzr1200service
luggage
index
restindex
zzr1200info
lifts
index
test1
test2
test3
The actual command I want to execute is:-
find info -name '*.txt' -exec mv `basename {} .txt`.rst \;
to change the .txt suffix to .rst.
Any ideas how to do it?
--
Chris Green
More information about the main
mailing list