Here we’re going to searching a text in a file using grep?

Searching a text in a file using grep, this command will be very much handy when searching in multiple files or folders in unix terminal.

grep is one of the powerful command used for searching in files or folder with the search pattern.

Searching for text in file using grep

Lets see how to search for text or string in files or folders using grep command

Command Usage:
grep [options] "search pattern"[regex] [filename/foldername]
Note: use double quotes for your search string

Options : (Below are frequently used options with grep command)
-i Ignores case
-n Print the line number
-c Count of matched pattern (Will not print the search line, rather it just prints the count)
-r Will search folders for matching text.
-v non-matched lines are printed

Try for yourself:

1) Search for any string and print count
hint: use -c
2) Search entire folder for match pattern with , (This is special symbol)
hint: “\,”
3) Search string by ignoring the case and also search for multiple string in a file
hint: use -v and in search string you need to split using | for multiple search string.

Try for yourself and comment it here https://youtu.be/9pUPUEvJop8

practice to keep FAMILIAR with the commands.

Subscribe to our channel for more videos : https://bit.ly/aryanz-youtube

https://youtu.be/9pUPUEvJop8
Searching a text in a file using grep
~3Minutes: Tutorial

Please disable your adblocker or whitelist this site! We Provide Free content and in return, all we ask is to allow serving Ads.

Pin It on Pinterest

Share This
%d bloggers like this: