Thursday, May 2, 2024
19
rated 0 times [  19] [ 0]  / answers: 1 / hits: 9199  / 1 Year ago, fri, december 2, 2022, 10:59:51

I use the grep command to search for a string in many files. Is there something similar to "search and replace"?


More From » command-line

 Answers
5

You are looking for the sed command. For example, to replace the "dog" with "cat" in all text files in the current directory:



sed -i 's/dog/cat/' *.txt

[#40605] Saturday, December 3, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hical

Total Points: 498
Total Questions: 106
Total Answers: 117

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
;