Answers for "replace string in linux file"

7

how to find and replace a string in a file using shell script

# replaces ALL(g i.e. global) ouccurences of "original_string" with "new_string", 
# in the file file_name.ext_name
sed -i 's/original_string/new_string/g' file_name.ext_name
Posted by: Guest on February-11-2021
1

linux substitute string

#replace all string occurence
sed -i 's/old-text/new-text/g' input.txt 

#replace all string occurence and create new file
sed -i 's/old-text/new-text/g' input.txt > newfile.txt

#see link 
#https://www.cyberciti.biz/faq/how-to-use-sed-to-find-and-replace-text-in-files-in-linux-unix-shell/
Posted by: Guest on January-04-2022

Code answers related to "replace string in linux file"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language