Updating the data from one file to the other


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Updating the data from one file to the other
# 1  
Old 11-19-2009
Updating the data from one file to the other

Hi,

Somebody please assist me in updating the data from one file to the other in Shell Scripting.

There are two files file1 and file2. Both the files have differen data but a common attribute. e.g. JAVA_HOME.

e.g. file1 has JAVA_HOME=/usr/j2se and
file2 has JAVA_HOME=/usr/jdk1.4.2

Now through shell script I want to update file1 content with the path of the JAVA_HOME provided in the file2.

I am not getting exactly how to use awk and sed for this operation.
# 2  
Old 11-19-2009
Try:

Code:
sed 's!\(JAVA_HOME=.*\)!'$(grep JAVA_HOME file2)'!' < file1 > file1_modified

# 3  
Old 11-19-2009
I'm sure there are some folks who know sed and awk much better than I do who can help you out. I'm curious if changing the JAVA_HOME in file2 is what you are trying to do, then have you thought about setting the JAVA_HOME in your profile and just referencing it with ${JAVA_HOME} in your scripts? This way, when the JAVA_HOME changes, all you have to do is change it once in your profile and the scripts will automatically reference the new home. Just a suggestion.
# 4  
Old 11-20-2009
Hi Dennis Jacob,

Your code really worked for me. Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Updating in file

hi, i have an csv(which is a month's log file containing userid and log in date ) file which has to be appended to another file say master.log.I need to compare the next month's log data to master.log file .In case, there is new log date for userid it has to get updated in master.log file or i... (2 Replies)
Discussion started by: preema
2 Replies

2. Shell Programming and Scripting

Run the Script from any stage by updating data from Oracle Table.

I have 100 Scripts, each containing 10-15 SQL's in them. Each Script run for 40 mins to 1 hour 30 mins. In the event of Failure in any step, if i re-start the Script, it will start running from the beginning. Which is waste of time. So in order handle this, i made the script to run from the... (7 Replies)
Discussion started by: kiran1992
7 Replies

3. UNIX for Dummies Questions & Answers

Updating a File

Hi, I have a below requirement and need your help in this regard. I have two timestamps in a file i.e. TimeBefore=2014-07-10.18.06.55 TimeAfter_1=2014-07-09.05.45.12 TimeAfter_2=2014-07-09.05.40.12 When I first run the script file, it sets the 'TimeBefore' to todays date. When I run... (5 Replies)
Discussion started by: vrupatel
5 Replies

4. Shell Programming and Scripting

Help updating a file

I can not seem to figure out how to update the attached match.txt column 2 using update.txt. However, only the text before the period in updat.txt appears in match.txt. For example, in update.txt NM_001613.2 matches NM_001613 in match.txt, so is it possible to update the record in match.txt to... (8 Replies)
Discussion started by: cmccabe
8 Replies

5. Linux

How to Keep your core System and personal Data safe while updating to latest distro?

Hi everyone, Almost everything is in the title! Which partitions do you keep? Which partitions do you reformat, while doing a clean install? Personaly, I never format /var and /home partitions when I update to latest linux distribution. It has been working quite ok up to now, but I was... (3 Replies)
Discussion started by: freddie50
3 Replies

6. Programming

updating data in cvs file using c programming

hi every one i want to read and write data from cvs file using c program. but my problem is that at run time my data is increasing in both row wise and column wise. that means it is continuously updating in both direction. is there any way through which i can find the next colum or row for eg... (0 Replies)
Discussion started by: sajidtariq
0 Replies

7. Shell Programming and Scripting

Updating data

Hi Guys, i currently facing a problem with a script i'm writing. I have a text file with the following data Windows in 21 days:John Goodman:29.90:30:19 I will like to know what method i can use so in order to edit the data in any of the field with ":" being the delimiter. example if i... (5 Replies)
Discussion started by: Cheranime
5 Replies

8. UNIX for Advanced & Expert Users

Updating entire column irrespective of any data in a file

Hi, I have a file A.txt (tab separated) as below: pavan chennai/tes/bangalore 100 sunil mangalore/abc/mumbai 230 kumar delhi/nba/andhra 310 I want to change only second column as below . Rest of columns as it is ;The ouput file is also tab... (4 Replies)
Discussion started by: kpavan2004
4 Replies

9. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies

10. Shell Programming and Scripting

TO know whether file is updating or not

Hi All, I am new to scripting. my requirement is , I want to know whether the file(i.e., log file) is updating or not. It should search for every 15 min. If it is not updating means it needs to send out a automatic mail. can you please help me in this. (2 Replies)
Discussion started by: raj333
2 Replies
Login or Register to Ask a Question