How to erase line in files containing string recursively in Linux

How to erase line in files containing string recursively in Linux

April 27, 2023
find . -name "*.md" -type f -exec sed -i '/line of text/d' {} \;

This command uses find to locate all .md files in the current directory and its subdirectories recursively. The -exec option is used to execute the sed command on each file found. The {} is replaced by the name of each file found, and the \; is used to terminate the -exec option.

The sed command removes any line containing the string “line of text” from each file found.