Context for Output of diff and grep

Command-line tools provide powerful text search and comparison capabilities on Unix and Linux systems. In particular, the diff and grep utilities are extremely popular for daily use. To add to the usefulness of output, try out the Context argument to view adjacent lines for reviewing text differences or matching grep items. Here is an example for 10 lines of context. Use the –help or man pages for more details on diff and grep context capabilities.

  • diff -C 10 file1 file2
  • grep -C 10 searchPattern fileName

Many thanks to the GNU developers for these essential tools. Read more at the official GNU project pages:


About notesbytom

Keeping technology notes on to free up my mind to solve new problems rather than figuring out the same ones repeatedly :-).
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s