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

Recommended Answers

All 5 Replies

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

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

Hope that helps :)

, Mike

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..

Can you post your code and the resulting output?

Thanks :)

, Mike

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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.