Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-03-2012
Registered User
 
Join Date: Jun 2012
Posts: 21
Thanks: 7
Thanked 0 Times in 0 Posts
Find a value inside file1 and replace it with another value from another fileB

i have a file with some data and i need replace a perticular value with some other value from another another file
req:
Code:
file1.txt
abc,idle.txt,1234

file2.txt
5678

now the requirement is need to replace the "idle.txt" is with "mike_5678" here 5678 from file2.txt...
file2.txt contains only one value but not always 5678. and mike is always constant.
expected result is..
Code:
file1.txt
abc,mike_5678,1234
¨

thanks in advance..

Siva Santosh

Moderator's Comments:
Please view this code tag video for how to use code tags when posting code and data.

Last edited by vbe; 07-04-2012 at 12:41 PM.. Reason: no fancy font stuff please
Sponsored Links
    #2  
Old 07-04-2012
elixir_sinari's Avatar
Gotham Knight
 
Join Date: Mar 2012
Location: India
Posts: 1,372
Thanks: 87
Thanked 478 Times in 458 Posts

Code:
read repl < file2.txt; sed 's/idle\.txt/mike_'"$repl"'/g' file1.txt

The Following User Says Thank You to elixir_sinari For This Useful Post:
dssyadav (07-04-2012)
Sponsored Links
    #3  
Old 07-04-2012
Registered User
 
Join Date: Jun 2012
Posts: 21
Thanks: 7
Thanked 0 Times in 0 Posts
Thanks a lot...

its working fine...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search from file1 and replace into file2 pparthiv Shell Programming and Scripting 2 05-25-2012 03:46 AM
Read Field from file1 and find and replace in file2 gdevadas Shell Programming and Scripting 8 04-07-2011 05:28 PM
Search & replace fields from file1 to file2 dragon.1431 Shell Programming and Scripting 2 03-02-2011 09:05 PM
how to find the pattern inside the file and replace it abhigrkist Shell Programming and Scripting 2 08-11-2010 07:09 AM
cat file1 read line-per-line then grep -A 15 lines down in fileb irongeekio Shell Programming and Scripting 6 01-28-2009 05:30 AM



All times are GMT -4. The time now is 07:33 AM.