Skip to content

Latest commit

 

History

History
executable file
·
33 lines (18 loc) · 1.13 KB

useful_grep_commands.md

File metadata and controls

executable file
·
33 lines (18 loc) · 1.13 KB

Useful grep commands

There are several useful grep commands for helping you find and/or replace text in multiple files. Examples:

List all files containing self.get_new_driver(, ignoring ".pyc" files, from the current directory:

grep -rl "self.get_new_driver(" * --exclude=\*.pyc

OR

grep -rl * -e "self.get_new_driver(" --exclude=\*.pyc


Replace all occurrences of "foo_abc" with "bar_xyz" on Linux, from the current directory:

sed -i 's/foo_abc/bar_xyz/g' *

Replace all occurrences of "foo_abc" with "bar_xyz" on macOS (file-backup required), from the current directory:

sed -i '.bak' 's/foo_abc/bar_xyz/g' *


Find all chromedriver processes (this combines ps with grep):

ps -ef |grep chromedriver


References: