In this Linux/Mac terminal tutorial, we will be learning how to use the grep command. The grep command allows us to search files and directories for patterns of text. You can also pipe the output of one command into grep to get certain matches. It’s extremely useful once you learn the ins and outs. Let’s get started…

The code from this video can be found at:

Regular Expressions Tutorial:
Regular Expressions Tutorial (Python):

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –

#Linux #Mac

Nguồn: https://codeigniterbrasil.com

Xem thêm bài viết khác: https://codeigniterbrasil.com/lap-trinh-linux/

20 Comments

PraiseHymnProject

April 16, 2020

Such a useful and straight forward video! Awesome!

Reply

Matt Dooley

April 16, 2020

I have this issue, can anyone help me? So, I sam searching for the word "Christmas" in a text file by doing the following:
grep "Christmas" filename.txt
And I got back the entire text of the file, printed out entirely in terminal! Unlike the video above, where simply got the number of the lines where the word appears, which is what I want for "Christmas" in my text file. What am I doing wrong?

Reply

Brendan Metcalfe

April 16, 2020

Thanks!

Reply

Mathew Boyd

April 16, 2020

I am very new to bash and was wondering how you go back to the previous command once you run it. For Ex 1:50

Reply

ramkiran55 devireddy

April 16, 2020

grep -i "John Willims" names.txt
How can I pass a string variable instead of "John Williams"

Reply

Maxwell Wibert

April 16, 2020

Unfortunately, it looks like homebrew has deprecated the –with-default-names option since the making of this video. Now in order to set gnugrep as the default grep you have to do some strange path manipulation in your bashrc/zshrc file. I don't fully understand how to do this, and was wondering if you might be able to explain the new method. I think you have to add a path to your gnubin in your rc file?

Reply

Sana Ali

April 16, 2020

Thank you for this very amazing and concise tutorial. You have summarized everything perfectly! Does . and ./* mean the same thing if I do grep r?

Reply

insanecbrotha

April 16, 2020

lol, the BRE for the phone numbers would be: grep "([[:digit:]]{3}-){2}[[:digit:]]{4}" names.txt

Could be worse though: http://ergoemacs.org/misc/emacs_lisp_toothpick_syndrome.html

Reply

camelCase

April 16, 2020

Which font do you use in the terminal?

Reply

Vineet gupta

April 16, 2020

Could you please make video on DS by python

Reply

Ian Hopper

April 16, 2020

Corey is simply the best.

Reply

MD Hossain

April 16, 2020

I like that this guy just gets straight to the point and wastes no time. I like this man already!

Reply

o

April 16, 2020

how grep "function" in php files that resides on remote server or localhost?

Reply

George Ford

April 16, 2020

FYI – the "–with-default-names" option has been removed. For Mac users who still want to use GNU grep as grep, see this helpful link: https://stackoverflow.com/questions/59232089/how-to-install-gnu-grep-on-mac-os

Reply

Mickaël Riga

April 16, 2020

Great video ! Great explanation. I like that it goes beyond the basic use. Thank you for sharing.

Reply

B R Pawan Kumar Iyengar

April 16, 2020

Great video … thank you

Reply

CrushOfSiel

April 16, 2020

So glad I looked at this tutorial. I've known how to kind of use grep for a while. Some of these options are going to be super helpful to me in the near future. I should have looked in the man pages a long time ago!

Reply

Khuen Lau

April 16, 2020

Thanks for creating this video, have been searching on how bash commands filter text files, can't find anything helpful, glad I searched it on Youtube.

Reply

mehmet rasim inceoglu

April 16, 2020

This was very informative. Thank you for the video.

Reply

Dielle

April 16, 2020

You should make an awk tutorial!

Reply

Leave a Reply