Thursday 5 May 2016

Search for string in a file and print the line : Unix basics

Guys, lets look into a very basic topic today. Today we'll see how to search for a string in a file and print the line in Unix/Linux/Mac OS X

Suppose I have a file SedText.rtf with the following text :

1.Here is a cute little tutorial for
2.trying out different things using
3.the Stream Editor or Sed in Unix.
4.The author of this tutorial is
5.none other than IroncladWriter
6.himself. The tutorial aims to
7.teach folks and educate how
8.they could unlock the power
9.of Unix to the fullest. Am posting
10.this on the blog IronCladZone
11.The best blog on the whole of
12.internet, where you can learn
13.technical stuff as well enjoy 
14.entertaining tidbits like movies,
15.music, television, fashion, food,
16.shopping, travel, trends etc.
17.Just sit back, relax and

18.ENJOY THE RIDE :)

Now I want to search this file for the keyword "Unix" and print all the lines. All we have to do is use the grep statement. Check this out :

grep Unix SedText.rtf
3.the Stream Editor or Sed in Unix.\

9.of Unix to the fullest. Am posting\

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker