| Author |
Newbie Question - Sed in all directories (including subs)
|
|
| webspazz@san.rr.com 2006-06-23, 7:32 am |
| I am using the following to change file extensions. Can anyone tell me
if I can modify this to change all files including all in every
sub-directory? Thanks
for file in *.asp ; do mv $file `echo $file | sed
's/\(.*\.\)asp/\1php/'` ; done
| |
| Sjoerd 2006-06-23, 7:32 am |
|
webspazz@san.rr.com wrote:
> for file in *.asp ; do mv $file `echo $file | sed
> 's/\(.*\.\)asp/\1php/'` ; done
Take a look at "find":
for file in `find . -name *.asp`
| |
| Duncan Muirhead 2006-06-23, 7:32 am |
| On Fri, 23 Jun 2006 02:06:49 -0700, webspazz wrote:
> I am using the following to change file extensions. Can anyone tell me
> if I can modify this to change all files including all in every
> sub-directory? Thanks
>
> for file in *.asp ; do mv $file `echo $file | sed
> 's/\(.*\.\)asp/\1php/'` ; done
I'd recommend "man find".
For example you could (I think) replace ".asp" above with
`find . -name "*.asp"` (note the back quotes)
or you could replace the for with a find (using the -exec action to
execute your sed)
Duncan
| |
| Robert Harris 2006-06-23, 1:22 pm |
| webspazz@san.rr.com wrote:
> I am using the following to change file extensions. Can anyone tell me
> if I can modify this to change all files including all in every
> sub-directory? Thanks
>
> for file in *.asp ; do mv $file `echo $file | sed
> 's/\(.*\.\)asp/\1php/'` ; done
>
For the rename, you could do:
mv $file ${file%.asp}.php
instead of invoking sed.
Robert
|
|
|
|