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 forwardC-r search backwardC-g return to where search started (if you are still in search mode)M-% query replaceSpace or y replace this occurenceDel or n don't replace. only replace this & exit (replace), replace & pause (resume with Space or y)! replace all following occurences^ back to previous matchRETURN or q quit replaceSearch/Replace with regular expressionsCharacters to use in regular expressions:^ beginning of line$ end of line. single char.* group or null of chars\< beginning of a word\> 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 forwardM C-r RETURN search for regular expression backwardM C-s incremental searchC-s repeat incremental searchM C-r incremental search backwardsC-r repeat backwardsM-x query-replace-regexp search & replace
No comments:
Post a Comment