943,660 Members | Top Members by Rank

Ad:
Jan 18th, 2008
0

Please help!! Related to making changes in file.

Expand Post »
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
Similar Threads
Reputation Points: 25
Solved Threads: 0
Light Poster
RohitSahni is offline Offline
35 posts
since Jul 2007
Jan 18th, 2008
0

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

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
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Jan 18th, 2008
0

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

Click to Expand / Collapse  Quote originally posted by eggi ...
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..
Reputation Points: 25
Solved Threads: 0
Light Poster
RohitSahni is offline Offline
35 posts
since Jul 2007
Jan 18th, 2008
0

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

Can you post your code and the resulting output?

Thanks

, Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Jan 18th, 2008
0

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

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.
Reputation Points: 25
Solved Threads: 0
Light Poster
RohitSahni is offline Offline
35 posts
since Jul 2007
Jan 18th, 2008
0

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

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.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: problem with relative pathing
Next Thread in Shell Scripting Forum Timeline: variable assignment and sed in bash script





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC