You are hereCode Snippets / Bash / Shell Scripting

Bash / Shell Scripting


Replace text in files

find . -iname \*.suffix | sed 's/ /\\ /g' | sed 's/#/\#/g' | xargs

alternatively:sed -i 's#old#new#gi'

Find a string in files

grep -lir "search text" *

The -l switch: list (outputs only the names of files in which the text occurs (instead of each line containing the text)), the -i switch: case insensitive (ignores the case), and the -r: recurse directories (descends into subdirectories).