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
Shell ScriptingPythonUnix OSLinux Distributions

Avatar of undefined
Last Comment
mac_g
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
mac_g
Flag of Saudi Arabia image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of mac_g
mac_g
Flag of Saudi Arabia image

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
Avatar of David Favor
David Favor
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
ASKER CERTIFIED SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of mac_g
mac_g
Flag of Saudi Arabia image

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
mac_g
Flag of Saudi Arabia image

ASKER

close this thread
Unix OS
Unix OS

Unix is a multitasking, multi-user computer operating system originally developed in 1969 at Bell Labs. Today, it is a modern OS with many commercial flavors and licensees, including FreeBSD, Hewlett-Packard’s UX, IBM AIX and Apple Mac OS-X. Apart from its command-line interface, most UNIX variations support the standardized X Window System for GUIs, with the exception of the Mac OS, which uses a proprietary system.

33K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo