Link to home
Create AccountLog in
Avatar of mac_g
mac_gFlag for Saudi Arabia

asked on

Shell Script : find and replace the text inside files with extension *.mvc files in current directory

Shell script :

find and replace the text inside files with extension *.mvc files in current directory
curval --to be translate to - newval
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Not that difficult:

sed -i 's/curval /newval/g' *.mvc

Try with one file first (testfile.mvc).
Avatar of mac_g

ASKER

it is working .. thank u
when to use -i option here ..
and also  .. if the curval - is very complex with special chars within ..like --- "(/(test/*^^^'"232)|)"
in that, this may behave differently ..

please advice how to handle such cases .. and if there any space with the string  ..
SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of mac_g

ASKER

can please elaborate point . didn't get it..
2 - choose a 'separator' that will not be in the complex set - maybe @ in your case?..
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of mac_g

ASKER

before closing this thread .. can you please advice
if the
cur val is   = abd@asd
new value = abd\@asdd

sed -i 's/abd@asd/abd\@asdd/g' 1.txt    -- this is not working ..
Avatar of mac_g

ASKER

close this thread