Grep command


Brief History

Grep command actually comes from ex editor. which was a very old text editor for UNIX. Still available btw.

Meaning of Grep

In ex editor if you wanted to search something this is you would do it:

:/pattern/p
        

p stands for print

If you wanted to print all the lines in a file this is how you would do:

where g is for global.

:g/pattern/p
        

Now, the thing is that “pattern” can be anything so can be replaced by Regular Expressions (RE)

So, therefore,

: g/RE/p

(global)/ (Regular Expression) / Pattern        

How GREP works?

grep word filename filename        

Say if you want to display all the processes running on your system, you can do that using grep

ps -ef | grep root
        

要查看或添加评论,请登录

Chinmay R.的更多文章

社区洞察

其他会员也浏览了