Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

sed replace in file

sed -i 's/foo/bar/g' hello.txt
Comment

replace using sed

#on my mac
sed -i -e 's/old-text/new-text/g' text.txt
Comment

sed replace

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'
Comment

sed replace into new file

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 
Comment

PREVIOUS NEXT
Code Example
Shell :: view memory usage linux 
Shell :: c interpreter 
Shell :: print file size in mb linux 
Shell :: github change commit date 
Shell :: spring boot docker hub image 
Shell :: how to move a file in bash 
Shell :: bash search history 
Shell :: scp send file to remote 
Shell :: shell cd 
Shell :: cocoapods 
Shell :: git create branch 
Shell :: terraform 
Shell :: bash shuffle lines 
Shell :: cordova could not install from "android" as it does not contain a package.json file. 
Shell :: Install/Deploy Sourcegraph with Docker 
Shell :: dev/ktm not found 
Shell :: dd command to add image to usb 
Shell :: dependencies to install python3.10 
Shell :: if you are using vm and installing ubuntu vm should we choose try ubuntu or install ubuntu 
Shell :: 3.4.5 packet tracer configure trunks 
Shell :: xsl fo when else 
Shell :: fast rename fasta header 
Shell :: how to open .mbox file ubuntu 
Shell :: Add the Inkscape repository to your apt package manager 
Shell :: gammu-smsd.service: Unit configuration has fatal error, unit will not be started. 
Shell :: oracle vm cannot install guest edition windows 10 enterprise 
Shell :: how many ppi is 4k 
Shell :: kubernetes using hyper v 
Shell :: asus router reset cache 
Shell :: launch tensorboard remotely 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =