Grep command
Chinmay R.
Software QA engineer @ Siemens Digital Industries Software | Experienced Product Development Engineer, CPU Performance Validation
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