Grep#
Grep itself is a simple tool built into Linux. It’s used for searching files or filtering a result set. While it is built into linux, it is also quite a powerful tool worthy of its own page. Theres alredy a whole lot of websites dedicated to grep so I don’t want to dive in too far.
Basic Syntax#
When trying to search a string in a result set. In the below, we are searching for “string” in the result set of “some query”
some query | grep “string”
We can also search a file by passing it as an arguement. Below we are searching for the sting “password” in the user.log file. You can also pass a directory and it will search all the files in the directory.
grep “password” user.log
In the above queries, we are searching for exact strings, but what if the case is wrong? There are a few flags that can help us
-i : ignore case
-E : pass a RegEx instead of a string…
-r : recursive search. when specifying a directory, also check its sub folders