[Bash] Search for Text with `grep`

In this lesson, we’ll use grep to find text patterns. We’ll also go over some of the flags that grep has that can be combined together to make it more powerful and easier to read.

grep --color -n -C 5 "npm.config.get" lib/**/*.js

# --color: highlight
# -n: show line number
# -C 5: show 5 lines for each context
# search for content "npm.config.get"
# in 'lib' folder for every matching js files

 

Can also using '-e' for regex partten.

Using `man grep` for help

原文地址:https://www.cnblogs.com/Answer1215/p/9790929.html