Pls Help - Need to edit file located in several directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pls Help - Need to edit file located in several directories
# 1  
Old 05-02-2007
Pls Help - Need to edit file located in several directories

I need to update an entry called "mail.RiskNavigatorFromEmailAddress" in all of the "Application.properties" files below, which are located in several different directories...

Each of these Application.properties files has the following entry:

mail.RiskNavigatorFromEmailAddress=oldemail@company.com

and I need to change it to

mail.RiskNavigatorFromEmailAddress=newemail@company.com

I dont want to go into each directory and vi the all of the files - it would take forever as there are a couple hundred of them ... is there an easier way to do this?


./uat304/com/company/rnj/config/Application.properties
./uat305/com/company/rnj/config/Application.properties
./uat309/com/company/rnj/config/Application.properties
./uat310/com/company/rnj/config/Application.properties
./uat307/com/company/rnj/config/Application.properties
./uat302/com/company/rnj/config/Application.properties
./uat312/com/company/rnj/config/Application.properties
./uat306/com/company/rnj/config/Application.properties
./uat314/com/company/rnj/config/Application.properties
./uat313/com/company/rnj/config/Application.properties
./uat315/com/company/rnj/config/Application.properties
./uat315/com/company/rnj/config/uat315/Application.properties
./uat315/com/company/rnj/config/client315a/Application.properties
./uat315/com/company/rnj/config/client315b/Application.properties
./uat317/com/company/rnj/config/Application.properties
./uat311/com/company/rnj/config/Application.properties
./uat324/com/company/rnj/config/Application.properties
./uat325/com/company/rnj/config/Application.properties
./uat307a/com/company/rnj/config/Application.properties
./uat307b/com/company/rnj/config/Application.properties
./uat316/com/company/rnj/config/Application.properties
./uat318/com/company/rnj/config/Application.properties
./uat319/com/company/rnj/config/Application.properties
./uat320/com/company/rnj/config/Application.properties
./uat322/com/company/rnj/config/Application.properties
./uat321/com/company/rnj/config/Application.properties
# 2  
Old 05-02-2007
#!/bin/ksh
for file in $(find . -name "Application.properties" -print); do
echo $file
sed -e 's/mail.RiskNavigatorFromEmailAddress=oldemail\@company.com/mail.RiskNavigatorFromEmailAddress=newemail\@company.com/g' < $file > ${file}.new && {
mv ${file}.new ${file}
}
done
# 3  
Old 05-02-2007
assuming your application.properties files are not over the place and only under ./*/com/company/rnj/config
Code:
# sed -i 's/\(mail.RiskNavigatorFromEmailAddress=\).*/\1newemail@mpa.gov.sg/' ./uat*/com/company/rnj/config/Application.properties
# sed -i 's/\(mail.RiskNavigatorFromEmailAddress=\).*/\1newemail@mpa.gov.sg/' ./uat*/com/company/rnj/config/*/Application.properties

# 4  
Old 05-03-2007
Thank you!

TinWalrus - Thanks! I had to do a couple of modifications and it worked like a charm! Your a savior!

ghostdog74 - Thanks for your response... the sed script didn't like the -i option, and when I removed the -i and ran it, it only changed the entry in the 1st file and none of the others... but again, with a little modification, I got it to work with ease.

Both of these were very helpful.. You responses are much appreciated!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sudo dmidecode where is the file located ?

Been through all my /sys /sbin /bin directories and can't seem to find it. (2 Replies)
Discussion started by: jcnewton13
2 Replies

2. Shell Programming and Scripting

use awk to edit a file..pls help

hey i want to over write the fourth field of a ':' delimited file by first finding the required row by using grep. i have done the following cat file | grep no. | awk -F ':' { $4=count; print $1:$2:$3:$4;} the correct values are being printed but nothin is bein added to the file..please... (5 Replies)
Discussion started by: dhe.arora
5 Replies

3. Shell Programming and Scripting

Need help to change the content for remote located file

Hi All, I have a file that sits on 4 diffrent servers, those servers are diffrent region based and they are authentication protected and that file has a diff port numbers, so when run the script it must ask my login details,region of server and port no for that file once it took from me it... (1 Reply)
Discussion started by: tmarjuna
1 Replies

4. Shell Programming and Scripting

Bash scripting to compare N number of files located in two directories

I want to compare "N" (around 2000+) number of huge files located in a directory A against "N" files located in a different directory using Bash scripting. Please help me with any scripts available. Thanks. (2 Replies)
Discussion started by: Sangtha
2 Replies

5. UNIX for Advanced & Expert Users

Need help to change the content for remote located file

Hi All, I have one file that sits on 4 diffrent servers, those servers are diffrent region based and they are authentication protected and that file has a diff port numbers, so when run the script it must ask my login details,region of server and port no for that file once it took from me... (1 Reply)
Discussion started by: tmarjuna
1 Replies

6. Shell Programming and Scripting

How do I go about finding a value located in one file in another?

Hi, I have to determine which VALID users made a failed loggon attempts on our server.To make a long story short, I have isolated the list of all the usernames and number of attempts in one file, and have isolated the valid users who have made failed loggon attempts in another file. I now have... (2 Replies)
Discussion started by: mojoman
2 Replies

7. UNIX for Dummies Questions & Answers

how to know the device on which the file is located

Hi, i want to know on which device a file is located is there any command or anyway to know it thanks santosh (5 Replies)
Discussion started by: santosh149
5 Replies

8. Shell Programming and Scripting

Deleting a file located on another server

Hi, I have successfully copied a file from one server to another using following command. user1@server1# scp test.jsp user2@server2:/home/ Now i want to delete that copied file(test.jsp) from "server2" by running some command from server1. Please help... (2 Replies)
Discussion started by: SanketJOSHI
2 Replies

9. UNIX for Dummies Questions & Answers

Deleting a file located on another server

Hi, I have successfully copied a file from one server to another using following command. user1@server1# scp test.jsp user2@server2:/home/ Now i want to delete that copied file(test.jsp) from "server2" by running some command from server1. Please help... (1 Reply)
Discussion started by: SanketJOSHI
1 Replies

10. Solaris

Where Xorg X-Lock file is located in Solaris?

I am using Xorg server with Solaris 10. After unnormal poweroff dtlogin tells: "The X-server can not be started on display :0" I am absolutelly sure it is because there is still a X-lock file from the previouse X-session somewhere, but I do not know where is it located in Solaris! :confused: (2 Replies)
Discussion started by: eugrus
2 Replies
Login or Register to Ask a Question