2019-08-27 1 minute read 0 Comments improve this post #command line | #linux

The grep command searches the given file for lines containing a match to the given strings or words. As an example, search ‘./package.json‘ for ‘gatsby-plugin-twitter‘:

$ export GREP_COLOR='1;37;41'
$ grep --color='auto' gatsby-plugin-twitter package.json
    "gatsby-plugin-twitter": "^2.1.2",

To search through all the files and directories for a given string such as ‘gatsby-plugin-twitter’, pass the -r (or --recursive) flag:

$ export GREP_COLOR='1;37;41'
$ grep -r --color='auto' 'gatsby-plugin-twitter' /tmp
/tmp/package.json:    "gatsby-plugin-twitter": "^2.1.2",

 Categories: #linux

Tech tips and command line fu found within this dojo