grep find and replace
Language: C - Grep Find and Replace
To find and replace text in files using the grep
command in C, you can use the following command:
grep -rl 'old_text' /path/to/directory | xargs sed -i 's/old_text/new_text/g'
This command uses grep
to find all files containing 'old_text' in the specified directory, and then uses xargs
and sed
to replace 'old_text' with 'new_text' in those files.
[[SOURCE #3]]