edit multiple files under multiple directories/folders
Tim H.
bizdev at pwnspeak.com
Sat Nov 27 08:11:59 UTC 2010
> Hi,
>
> In my home folder I have 6 tomcat directories under
> /home/kaushal/tomcat0......6
>
> Under each of these tomcats there are sub folder conf and inside these
> conf there is a file by the name server.xml so for example I have
> tomcat0,tomcat1,tomcat2,tomcat3,tomcat4,tomcat5 so i need to edit
> server.xml and set port numbers for tomcat0 to 8080 tomcat1 to 8081 and
> similarly for others,the other way is to go to individual directory and
> do it
>
> Please suggest/guide
>
> Thanks and Regards
>
> Kaushal
>
I little server administration script would do. Something with the sed
command:
echo tomcat*/server.xm | sed s/80/8081/g
If you wish to give a different port for each, use a for loop. This is
not correct but the right idea:
#!/bin/bash
port=8080
for var in `find ./ -name server.xml`
do
echo $var | sed s/80/$port/g
port=$((port + 1))
done
This is assuming the script already has port 80 as the default. Just
find what it is exactly you need to search for to alter it with 'sed'.
Tim H.
blog.pwnspeak.com
More information about the ubuntu-users
mailing list