using_grep

This is an old revision of the document!


Using GREP



Grep is a super useful tool, but it is difficult to master, so in this section we are going to explore some examples of the use of GREP. Grep can be as complex as your imagination can muster, but some very simple examples of Grep use will get you started nicely.

The name, “grep”, derives from the command used to perform a similar operation, using the Unix/Linux text editor ed: g/re/p

grep command syntax

The syntax is as follows:

  grep 'word' filename
  grep 'word' file1 file2 file3
  grep 'string1 string2' filename
  cat otherfile | grep 'something'
  command | grep 'something'
  command option1 | grep 'data'
  grep --color 'data' filename



How do I use grep command to search a file?

Search /etc/passwd file for boo user, enter:

  grep boo /etc/passwd


using_grep.1473185994.txt.gz · Last modified: 2023/03/09 22:35 (external edit)