Search and replace in Linux

Search in multiple files & replace in terminal

grep -lr -e 'oldword' * | xargs sed -i 's/oldword/newword/g'

Search & replace in vi

esc : %s/oldword/newword/g

Search & replace in emacs

C-s Search forward C-r search backward C-g return to where search started (if you are still in search mode) M-% query replace Space or y replace this occurence Del or n don't replace . only replace this & exit (replace) , replace & pause (resume with Space or y) ! replace all following occurences ^ back to previous match RETURN or q quit replace Search/Replace with regular expressions Characters to use in regular expressions: ^ beginning of line $ end of line . single char .* group or null of chars \ end of a word [] every char inside the backets (for example [a-z] means every small letter) M C-s RETURN search for regular expression forward M C-r RETURN search for regular expression backward M C-s incremental search C-s repeat incremental search M C-r incremental search backwards C-r repeat backwards M-x query-replace-regexp search & replace