Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

replace using sed

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

sed replace all until match in line

echo remove_staystay... | sed 's/.*(stay.*)/1/g'
stay	#remove all but from last ocurrence match until end
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 from match

Just use a similar example with using ".*" regex with sed as following:
sed 's/match_pattern.*/replacement_of_match_and_rest_of_line/' file.txt
Comment

PREVIOUS NEXT
Code Example
Shell :: remove mac ._ files windows 
Shell :: create public key linux 
Shell :: grep first match 
Shell :: search in github repo 
Shell :: postgre create user 
Shell :: github status 
Shell :: umount device is busy 
Shell :: install wordpress on xampp 
Shell :: github commands 
Shell :: install jenkins ubuntu 
Shell :: powershell merge csv files 
Shell :: Unit Tests 
Shell :: docker install google chrome 
Shell :: install docker on ubuntu 
Shell :: copy files from another branch git 
Shell :: how to push existing git repository 
Shell :: install flathub in linux elementary 
Shell :: swap ctrl and caps lock linux 
Shell :: packet tracer 2.7.1 Full Config BC-2 Router 
Shell :: rasberry pie gsm internet browsing 
Shell :: IBM rpc mount export: RPC: Unable to receive; errno = No route to host 
Php :: enable php error 
Php :: check if session is started php 
Php :: is frontpage wordpress 
Php :: get start of month end of month carbon 
Php :: how to get page name in php 
Php :: laravel password confirmation 
Php :: rout debug symfony command 
Php :: how to add two array in single array without repetation in php 
Php :: how console log laravel 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =