Please help!! Related to making changes in file.

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2007
Posts: 35
Reputation: RohitSahni is an unknown quantity at this point 
Solved Threads: 0
RohitSahni RohitSahni is offline Offline
Light Poster

Please help!! Related to making changes in file.

 
0
  #1
Jan 18th, 2008
Hi all,

The scenario is like this: i have one file which contains some particular paths, now my aim is to make changes in this file so that i can change the path in that file.. eg:

file1.txt:

ABC
-p /home/user/a/b/v23.9/library -l /home/user/a/b/ABC/v23.9 test.exe
DEF
-r v23.9 /c/d/f -p /home/user/a/b/v23.9/library -l /home/user/a/b/ABC/v23.9 test.exe

end of file1.txt

now i want to change only this 'v23.9' to 'abcde' that to only in both the paths.
I tried using "tr" but it changes all the v23.9 in this file.

Can anyone please suggest me any solution.

Thansk
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Please help!! Related to making changes in file.

 
0
  #2
Jan 18th, 2008
Hey there did you try tr and specify only alpha characters?

Shell Scripting Syntax (Toggle Plain Text)
  1. tr '[:upper:]' '[:lower:]'

Hope that helps

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 35
Reputation: RohitSahni is an unknown quantity at this point 
Solved Threads: 0
RohitSahni RohitSahni is offline Offline
Light Poster

Re: Please help!! Related to making changes in file.

 
0
  #3
Jan 18th, 2008
Originally Posted by eggi View Post
Hey there did you try tr and specify only alpha characters?

Shell Scripting Syntax (Toggle Plain Text)
  1. tr '[:upper:]' '[:lower:]'

Hope that helps

, Mike
yup man i did tried this...but not working..
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Please help!! Related to making changes in file.

 
0
  #4
Jan 18th, 2008
Can you post your code and the resulting output?

Thanks

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 35
Reputation: RohitSahni is an unknown quantity at this point 
Solved Threads: 0
RohitSahni RohitSahni is offline Offline
Light Poster

Re: Please help!! Related to making changes in file.

 
0
  #5
Jan 18th, 2008
output:

$ tr "/v23.9" "/ABCDE" < test.txt
ABC
-p /home/user/a/b/ABCDE/library -l /home/user/a/b/ABC/ABCDE testDexe
DEF
-r ABCDE /c/d/f -p /home/user/a/b/ABCDE/library -l /home/user/a/b/ABC/ABCDE testDexe

i dont want these RED color items to change but want only green colur items.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Please help!! Related to making changes in file.

 
0
  #6
Jan 18th, 2008
Assuming you mean the v23.9 directly after the -p argument

Shell Scripting Syntax (Toggle Plain Text)
  1. sed -e 's;/v23.9/;/abcde/;g' file1.txt > file2.txt

If you mean after the -p and after -l arguments then
Shell Scripting Syntax (Toggle Plain Text)
  1. sed -e 's;/v23.9;/abcde;g' file1.txt > file2.txt
Last edited by masijade; Jan 18th, 2008 at 3:46 am.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC