954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Please help!! Related to making changes in file.

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

RohitSahni
Light Poster
35 posts since Jul 2007
Reputation Points: 25
Solved Threads: 0
 

Hey there did you try tr and specify only alpha characters?

tr  '[:upper:]' '[:lower:]'


Hope that helps :)

, Mike

eggi
Posting Pro in Training
400 posts since Oct 2007
Reputation Points: 102
Solved Threads: 47
 

Hey there did you try tr and specify only alpha characters?

tr  '[:upper:]' '[:lower:]'

Hope that helps :)

, Mike

yup man i did tried this...but not working..

RohitSahni
Light Poster
35 posts since Jul 2007
Reputation Points: 25
Solved Threads: 0
 

Can you post your code and the resulting output?

Thanks :)

, Mike

eggi
Posting Pro in Training
400 posts since Oct 2007
Reputation Points: 102
Solved Threads: 47
 

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.

RohitSahni
Light Poster
35 posts since Jul 2007
Reputation Points: 25
Solved Threads: 0
 

Assuming you mean the v23.9 directly after the -p argument

sed -e 's;/v23.9/;/abcde/;g' file1.txt > file2.txt


If you mean after the -p and after -l arguments then

sed -e 's;/v23.9;/abcde;g' file1.txt > file2.txt
masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You