grep


 2019-08-27 1 minute read 0 Comments #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",

See Also

  • Bash Tips and Tricks — shell scripting patterns to build on your grep one-liners
  • sed — stream editor for transforming the lines that grep finds
  • xargs — pipe grep results into other commands for batch processing

 Categories: #linux


AI prompts, command-line cheat sheets & developer tips — prompt engineering guides, LLM evaluation tools, and AI tools for developers building with modern language models.

 2026