Searching Through Files - Finding A Particular String And Updating It

Main command: grep -rnw "xA" -e "xB" | xargs sed -i 's/xC/xD/'

If you see on the example below, you would use the grep command up to the pipe symbol first without -l, then add it in afterwards. This is used after searching for strings. The letter L is for grep’ing just the directory location where it finds the result and not actually showing file contents.

SED WILL NOT work if you do not add -l into the -rlnw. It has to require the absolute paths and not anything else it outputs.

An Example

Searching through LuckPerms configs in all servers to replace connection timeout string.

grep -rlnw "connection-timeout: 5000" */plugins/LuckPerms | xargs sed -i 's/connection-timeout: 5000/connection-timeout: 20000/'


Revision #1
Created 4 February 2024 01:43:03 by JasmeowTheCat
Updated 2 May 2024 23:24:35 by JasmeowTheCat