variables - sed replacing without untouching a string -


im trying replace lines within files contains:

/var/www/webxyz/html

to

/home/webxyz/public_html

the string: webxyz variable: web1, web232

so string before , after webxyz should replaced. tried without solution:

sed -i 's/"var/www/web*/html"/"home/web*/public_html"/g' 

also want should check , replace files (inclusive subdirectory , files), * operator don't work.

within regular expression, you’ll need escape delimiting character surround them, in case /. can use different delimiter ,:

sed -i 's,"var/www/web*/html","home/web*/public_html",g' 

but working intended, you’ll need remove " , replace b* (sed doesn’t understand globbing wildcards) this:

sed -i 's,var/www/web\([^/]*\)/html,home/web\1/public_html,g' 

here \([^/]*\) used match after web except /. matching string referenced \1 in replacement part.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -