grep command:
The grep command is a tool used for searching and manipulating text patterns in the files.
Its name is derived from the unix ed (editor) command g/re/p (global search for regular expression and print it)
grep [options] pattern [files]
1) Normal search :
grep "Techno" test_grep.dat
2) Case insensitive search :
grep -i "techno" test_grep.dat
3) Matching the lines that start with a string
grep "^techno" test_grep.dat
4) Matching the lines that end with a String
grep "techno$" test_grep.dat
5) Count the number of matches
grep -c "techno" test_grep.dat
6) Display the file Names that matches the pattern
grep -l "techno" test_grep.dat
7) Search for Whole Words in a file
grep -w "techno" test_grep.dat
8) Displaying only the matched patterns
grep -o "techno" test_grep.dat
9) Display line number While displaying the Output
grep -n "techno" test_grep.dat
10) Inverting the Pattern , which is not found display those lines.
grep -v "techno" test_grep.dat
11) Search recursively for a pattern in the directory
grep -R techno /home/technocoders/test_shell
e.g, file :
test_grep.dat
Welcome to technocoders, this file is to test how the grep command works.
Technocoders channel is created to help the coders to speed up in coding skills.
Using this file we will serach for technocoders to see how it works.
Thanks for you time, please subscribe to technocoders.
Thank you!
------------------------------------------------------------
#unix #unixtutorial #unixcommands #linux #linuxcommands #learning #coding #grep
Негізгі бет Unix Basics Part 10 | grep | Frequently used commands | search text patterns
Пікірлер: 1