Question : replace text with sed
Answered by : clear-caterpillar
sed -i 's/old-text/new-text/g' input.txt
Source : | Last Update : Tue, 07 Apr 20
Question : sed replace in file
Answered by : alex-h-raber
sed -i 's/foo/bar/g' hello.txt
Source : https://www.cyberciti.biz/faq/how-to-use-sed-to-find-and-replace-text-in-files-in-linux-unix-shell/ | Last Update : Sun, 08 Mar 20
Question : replace using sed
Answered by : worrisome-wasp-lx7coql5e4pi
#on my mac
sed -i -e 's/old-text/new-text/g' text.txt
Source : | Last Update : Thu, 03 Dec 20
Question : sed replace
Answered by : armando-flores
For using match in sed replacement, just border it with '\(' and '\)':
echo Before123 | sed 's/Before\([0-9]*\)/\1After/g'
123After # number is matched withtin '\( \)' and replaced in '\1'
Example with 2 match replacements
echo a_b | sed 's/\(^.*\)_\(.*$\)/first is \1 and \2 is after/g'
Source : | Last Update : Fri, 04 Dec 20
Question : sed replace into new file
Answered by : leonard
You can try this sed command
sed 's/,\(.*china\)/,Tomas_proxy.lt\/\1/' FileName
or
sed 's/,\(.*china\)/,Tomas_proxy.lt\/\1/' FileName > NewFile
or
sed -i.bak 's/,\(.*china\)/,Tomas_proxy.lt\/\1/' FileName
Source : https://stackoverflow.com/questions/28044054/linux-unix-replacing-a-pattern-in-a-string-and-saving-to-a-new-file-with-sed | Last Update : Wed, 27 Apr 22
Question : sed file replace
Answered by : netrock
sed -i 's/SEARCH_REGEX/REPLACEMENT/g' INPUTFILE
Source : https://linuxize.com/post/how-to-use-sed-to-find-and-replace-string-in-files/ | Last Update : Tue, 23 Nov 21