Linux/Mac Terminal Tutorial: The Grep Command - Search Files and Directories for Patterns of Text

  Рет қаралды 356,128

Corey Schafer

Corey Schafer

Күн бұрын

Пікірлер: 242
@whenthethebeansstrikeback6728
@whenthethebeansstrikeback6728 5 жыл бұрын
I like that this guy just gets straight to the point and wastes no time. I like this man already!
@richardgray8593
@richardgray8593 3 жыл бұрын
I'd like it even better if he would take just a sec to give a shout-out to the Greatest President That Ever Was or Ever Will Be, Donald J. Trump.
@caitlingibbons2246
@caitlingibbons2246 3 жыл бұрын
@@richardgray8593 LOL! Don the Con is a sociopathic narcissist. He is, and will always be, the worst "president" to ever trespass in The White House. Good riddance to this parasite.
@richardgray8593
@richardgray8593 3 жыл бұрын
@@caitlingibbons2246 You are pathetically stupid to post something like this. Every day, Joe and the Ho are showing us what a great president Trump truly was.
@latlov
@latlov 4 жыл бұрын
6:35 $ grep -win -C 2 "find this string" ./* 8:05 $ grep -winr "Find that string even in subdirs" ./* 9:35 $ grep -wirl "List those files that contain this string in current directory dot" . 10:20 $ grep -wirc "List those files that contain this string and number of occurrences in current directory dot" . 11:10 $ history | grep "search for git commits in history" 12:00 $ history | grep "search for git commits" | grep "now narrow down to some string" 15:40 only for mac: $ brew install grep --with-default-names #to allow regular expressions based on perl, as shown in 17:56. 19:13 Homework!
@someone-x64
@someone-x64 3 жыл бұрын
Thank you ☺️😀
@lambdacodes-r3w
@lambdacodes-r3w 6 ай бұрын
Thanks
@MrTommycat95
@MrTommycat95 3 жыл бұрын
Some folks are intelligent and smart but are horrible at teaching. Corey is smart, intelligent and born to be a teacher. While I am going to contribute on patreon right away, you have a gift that you can use to sell your videos at a small price to benefit and educate the population. Amazing
@Spladoinkal
@Spladoinkal 7 ай бұрын
Wow your tutorial made grep SO much simpler. Thanks!
@VishKnew
@VishKnew 4 жыл бұрын
Mann....You are a legend...Only few people are out there like you..You really are a gemstone. Thank you soo much for this awesome tutorial brother ❤️ No wasting time, straight to the point. God bless you. Love from Kerala ❤️
@thrilochanpakkapoti99
@thrilochanpakkapoti99 3 жыл бұрын
After seeing one video, i am addicted to watch more. Thank you friend
@uuzumakifox9
@uuzumakifox9 4 жыл бұрын
I just ended up watching your Python OOP series. and i randomly looked for some Linux tutorials, and i was SOOO happy to see your name!
@binta9
@binta9 8 ай бұрын
very easy to understand :) thank you!!
@msurajnair7149
@msurajnair7149 4 жыл бұрын
There are very few tutorial which gets straight to the point, this is one of them. Really enjoyed learning, Extremely instructive. Thank you.
@andremorency
@andremorency 5 ай бұрын
Great tutorial. Now I understand the grep command much better and I'm looking forward to understand more about regular expressions. Thank You !
@spot1401
@spot1401 6 жыл бұрын
Coincidentially, I had just tried out grep yesterday after completing the "Terminus" game. Today my colleague was very impressed when in a matter of seconds, out of 7500 case files, I picked those 40 or so which contained one certain word. also you can export the results easily into a file (I use &>>filename.txt (.csv also works)), which might come in handy if your boss wants "all the contracts with the Miller Company ASAP", or if you want to quickly mail a list of relevant files. As always, great video!
@coreyms
@coreyms 6 жыл бұрын
Nice! Yeah, knowing the command line is a great way to do tasks like this and is a lot more time efficient than writing a complete program from scratch to do the same functionality.
@spot1401
@spot1401 6 жыл бұрын
I think back to the days where I literally let Windows XP search through "all .doc files, look for existence of expression Blabla" over the whole FRIGGIN WEEKEND! I think back in shame of course :) One day, I will make a video explaining how I turned an unsorted mess of 15 years unsorted .doc files into a searchable database over a weekend and I will refer a lot to you. Thanks man!
@midokoudaih290
@midokoudaih290 6 жыл бұрын
This is exactly what I'm looking for, a way to search for a certain word within 10-20K of case files, located on different drives. I usually use mdfind "word" but it doesn't always work on pdf files, do you mind sharing that method/command you used to find those files?
@soumitripattnaik
@soumitripattnaik 6 жыл бұрын
These days I hit like as soon as I click on the video, I know it's going to be awesome anyway :)
@CrushOfSiel
@CrushOfSiel 5 жыл бұрын
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!
@ahmedmahdy6036
@ahmedmahdy6036 6 жыл бұрын
awesome ...I really like your style in explanation Corey which i feel like i'm enjoying while watching your tutorials :)
@kenthn5396
@kenthn5396 4 жыл бұрын
I like how this was explained. Straight to the point and simple, very easy to understand.
@younesmdarhrialaoui643
@younesmdarhrialaoui643 Жыл бұрын
Excellent. Straight to the point. Concise and precise. Love it 🤩
@iandthopper
@iandthopper 5 жыл бұрын
Corey is simply the best.
@mathewkargarzadeh3158
@mathewkargarzadeh3158 6 жыл бұрын
outstanding !!!. Dear Corey, appreciate for your time posting your tutorials. I am enjoying teaching style. Thanks again!!
@khuenlau4602
@khuenlau4602 5 жыл бұрын
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 KZbin.
@mickaelriga8169
@mickaelriga8169 5 жыл бұрын
Great video ! Great explanation. I like that it goes beyond the basic use. Thank you for sharing.
@kenchiken6338
@kenchiken6338 2 жыл бұрын
This video is definitely getting saved for future use
@ilgas11
@ilgas11 4 жыл бұрын
the only youtuber to speak at playback speed 1.5 by default! :D
@j0hn4th4nd03
@j0hn4th4nd03 5 жыл бұрын
Clearest most concise tutorial I have found! Thank you!
@PoeLemic
@PoeLemic 4 жыл бұрын
Thanks for covering this. Man, do you make things understandable and simple. I wish that I would have just used KZbin to learn Linux, instead of doing a community college course.
@RahulDubey121
@RahulDubey121 2 жыл бұрын
Another awesome video from one of the greatest online tutors.. Hats off, corey. With lots of Love from India :)
@markslima1557
@markslima1557 4 жыл бұрын
Finally a great explanation of GREP for Mac terminal nerds like me! GOLD!
@nappingyiyi
@nappingyiyi 3 жыл бұрын
thank you so much for talking about the BSD grep and GNU grep!! i stuck there for so long ;-;
@JordanCrawfordSF
@JordanCrawfordSF 6 жыл бұрын
Brilliant. Thank you for taking the time to help me understand grep, I really appreciate your thoughtfulness Corey.
@Hamzaelbouti
@Hamzaelbouti 6 жыл бұрын
YOU ARE AMAZING ...... DO NOT EVER STOP
@benwalsh2825
@benwalsh2825 5 жыл бұрын
Great video as always. Our company has switched from Windows to Mac, and I find all of these videos supremely helpful while transitioning. Also, I find it interesting that Gnu is pronounced Gah-new when referring to the software, but just "New" when referring to the animal; sort of like Dvorak the composer (pronounced: d(ə)-VOR-zha(h)k) vs Dvorak the professor/keyboard designer I guess. Thanks again!
@coreyms
@coreyms 5 жыл бұрын
Glad you find the videos helpful! As far as the pronunciation, if you're interested there's a short clip on this site with the author explaining how he came out with the pronunciation. Kind've humorous and interesting: www.gnu.org/gnu/pronunciation.en.html
@benwalsh2825
@benwalsh2825 5 жыл бұрын
@@coreyms Well that is really cool! Thank you for sharing it! Gnu has always been my favorite word choices when playing Hangman with folks for the first time. Almost always wins. :)
@apolodu7852
@apolodu7852 2 жыл бұрын
You've made learning these commands so easy, great job and thank you!
6 жыл бұрын
He's really an amazing guy. I watch this even I know this. So addicted. Suggestion: put an xargs video :-)
@filthyE
@filthyE 5 жыл бұрын
Good suggestion! xargs is so useful!
@yogi30303
@yogi30303 3 жыл бұрын
Man, you're awesome. You made everything sound so easy.
@tomaspyth7017
@tomaspyth7017 5 жыл бұрын
Hi corey, well done like always 👍👍 thanks Nevertheless i would like to add a trick if you didn't already know that When you use history and grep you could wrap the g of grep in a square braquets in order to not get the command itself in the output of the matched results... History | [g]rep
@praisehymnproject319
@praisehymnproject319 4 жыл бұрын
Such a useful and straight forward video! Awesome!
@abdelazizabdelioua890
@abdelazizabdelioua890 5 жыл бұрын
Continue adding courses, you are awesome man, watching your videos makes it both enjoying and learning
@evrensen1520
@evrensen1520 5 жыл бұрын
I love your tutorials. Really enjoyable. Thanks a bunch.
@andylib
@andylib 5 жыл бұрын
A video of pure perfection
@subhamraoniar5180
@subhamraoniar5180 3 жыл бұрын
Amazing video, exactly what I wanted
@falkelh
@falkelh 3 жыл бұрын
I really like your shells theme! Its also a great tutorial!
@genericusername555
@genericusername555 5 жыл бұрын
Excellent tutorial.
@yash1152
@yash1152 Жыл бұрын
searching for "regular" in the transcript pane of youtube desktop, go here: 12:18 > _"... more advanced searches using regular expressions now I'm not going to go into detail about how to write regular expressions in this video but if you're interested then I'll put a link to my regular expression videos in the description section below. So grep uses POSIX regular expressions by default now ..."_
@arunsinghchouhan5541
@arunsinghchouhan5541 4 жыл бұрын
Nicely explained. Thanks!
@kalef1234
@kalef1234 6 жыл бұрын
finally a nicely done video on this! Thanks
@tamirsasi
@tamirsasi 4 жыл бұрын
The video is excellent, very clear, I learned a lot
@vathsama
@vathsama 5 жыл бұрын
excellent video, a good start for grep...much appreciated
@kevinduigou3212
@kevinduigou3212 6 жыл бұрын
Simple and clear. Thank you!
@LuvxJacqu4li8e
@LuvxJacqu4li8e 2 жыл бұрын
Very nice never bothered to learn it before but great video
@katexie1069
@katexie1069 2 жыл бұрын
Thank you!! This tutorial is super helpful!!
@hackpens2246
@hackpens2246 3 жыл бұрын
Fantastic video. I learnt some great options today. Thank you very much!
@moha_linus
@moha_linus 5 жыл бұрын
I'm really so happy beacause i found this channel Ur the best wallh ... sorry for my bad english
@lokeshkoliparthi9268
@lokeshkoliparthi9268 2 жыл бұрын
For any youtube searches, If I see your video I would just open it
@linuxmitra7694
@linuxmitra7694 4 ай бұрын
Crisp n clear , thanks 😊
@skinnymanua
@skinnymanua 2 жыл бұрын
Once I fell asleep on the keyboard typing grep arguments and it showed me the path to the 5th demension
@experimentalhypothesis1137
@experimentalhypothesis1137 5 жыл бұрын
best as always. your videos are superuseful
@jannywong714
@jannywong714 4 жыл бұрын
Homebrew UPDATE Aug 2020 If you're a mac user and want to use corey's homebrew trick, read on... At 16:07 Corey says to use this command: brew install grep --with--default-names I tried doing this and it doesn't work. Per a google search that optional argument is no longer allowed. Here's the work-around. 1. Inside terminal: *brew install grep* 2. inside your .bashrc file, put this line of code, preferably at the top so this path is checked first: *export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"* 3. open a new terminal window (command+n) and type in *grep -V* . Should say GNU grep.
@nicholasbarning8250
@nicholasbarning8250 5 жыл бұрын
awesome video and easy to understand! THANK YOU!
@sekander1253
@sekander1253 3 жыл бұрын
Excellent tutorial! Thanks a ton for sharing.
@hanac5586
@hanac5586 2 жыл бұрын
Wonderfully explained
@arborinfelix
@arborinfelix 5 жыл бұрын
This was very informative. Thank you for the video.
@MariaFlorenciay
@MariaFlorenciay 6 жыл бұрын
Very well explained! :D
@Lukas-wm8dy
@Lukas-wm8dy 4 жыл бұрын
In case any one is having issues with the --with-default-names flag on Mac - it is apparently not available anymore in the latest version of homebrew. One workaround that worked for me is to 1. install the package via "brew install grep"; 2. set up an alias pointing from grep to ggrep. You can do this by adding 'alias grep='ggrep' somewhere in your .bash_profile file. Steps: 1. brew install grep 2. nano ~/.bash_profile 3. (add 'alias grep='ggrep' somewhere in the file and then save it) 4. open new terminal for the change to become effective 5. check with grep -V (should display "ggrep (GNU grep) ...")
@sabitkondakc9147
@sabitkondakc9147 2 жыл бұрын
it was rather helpful, great thanks for the contents.
@renergoncalveslopes
@renergoncalveslopes 2 жыл бұрын
You're the best! Thanks again.
@TJKhara
@TJKhara 4 жыл бұрын
Thank you great video!
@maspoetry1
@maspoetry1 4 жыл бұрын
great tutorial, thanks! Not sure if you did it purposely but -win is an easy, useful flag to remember
@卡机不
@卡机不 4 жыл бұрын
you saved my day sir, thank you so much
@goddardpk
@goddardpk 3 жыл бұрын
Hi Corey, thanks for last bit on Mac BSD grep distinction!
@jamesyen98
@jamesyen98 4 жыл бұрын
This is very helpful, thank you very much!
@brpawankumariyengar4227
@brpawankumariyengar4227 5 жыл бұрын
Great video ... thank you
@cwash08
@cwash08 6 жыл бұрын
Nice tutorial, I see there''s also a find tutorial too. I'll check it out. I always am confused between both of them
@HSfox
@HSfox 3 жыл бұрын
This made so much sense :D
@techwithshudarsan559
@techwithshudarsan559 3 жыл бұрын
It was helpful for me. Thank you
@andresriffo4036
@andresriffo4036 6 жыл бұрын
Just AMAZING! Thank You!!
@LuisJimenezr01
@LuisJimenezr01 5 жыл бұрын
YOUR CONTENT IS SO UNDERRATED!! THANK YOU SO MUCH FOR YOUR HELP!!
@samkotha1645
@samkotha1645 6 жыл бұрын
awesome explanation tq sir
@shubho5das
@shubho5das Жыл бұрын
Brilliant, thank you!
@majki5900
@majki5900 4 жыл бұрын
awesome tutorial, full of details. Thanks for that ! Subscribed ;)
@patriciamirelladasilvascar1011
@patriciamirelladasilvascar1011 3 жыл бұрын
That's a great video!
@aravind4444
@aravind4444 5 жыл бұрын
really useful stuff
@hedleypanama
@hedleypanama 6 жыл бұрын
I thinkl you forgot the -v option that matches everything but the pattern! Anyway, I learn a lot! thanks for your nice video!
@serhiypidkuyko4206
@serhiypidkuyko4206 4 жыл бұрын
1. one can't use the "\d" for the digit in grep/egrep (if not use "-P") 2. to use "{3}" for "three times" one need to use 'egrep' instead of 'grep' (if not use "-P") 3. there is no option "--with-default-names" 4. => one need to install "brew install grep" and use 'ggrep/gegrep' instead of 'grep/egrep' 5. there is a very useful option "--color" to highlight found items (as well as filenames and row numbers when using GNU grep)
@manuelapostol7664
@manuelapostol7664 4 жыл бұрын
THANK YOU SO MUCH
@digitalaks
@digitalaks 6 жыл бұрын
Great video... You could have mentioned about grep -v option too.
@MrJaylassiter
@MrJaylassiter 4 жыл бұрын
Thank you!
@JAWang1994
@JAWang1994 2 жыл бұрын
great explanation
@martintouko8359
@martintouko8359 3 жыл бұрын
fantastic thanks . god bless man!!!
@Gaplix
@Gaplix 6 жыл бұрын
i luv this guy
@quentinguillot3850
@quentinguillot3850 2 жыл бұрын
Hello Corey, when i enter the option --with-default-names. I have an error saying "Error : invalid option : --with-default-names". How i can fix it please ?
@rotamagzine
@rotamagzine 6 жыл бұрын
You are the best
@sam2223
@sam2223 3 жыл бұрын
your videos are great
@maxwibert
@maxwibert 4 жыл бұрын
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?
@jwesleyb1
@jwesleyb1 3 жыл бұрын
brew install grep alias grep='ggrep -P' # in .zshrc
@ghost31313
@ghost31313 Жыл бұрын
thank you very well done
@BrendanMetcalfe
@BrendanMetcalfe 4 жыл бұрын
Thanks!
@wetwinz5905
@wetwinz5905 4 жыл бұрын
Good job bro
@ManishKumar-ou5mo
@ManishKumar-ou5mo 5 жыл бұрын
Corey bhaiya ki jai ho... :D
@rajivraghu9857
@rajivraghu9857 5 жыл бұрын
Well made stuff..
@Lumary
@Lumary 5 жыл бұрын
awesome,thank you! :)
@NikhilCherianKurian
@NikhilCherianKurian 2 жыл бұрын
Hey, thanks for the great tutorial, btw how did you create a custom zsh / bash session for theses tutorials?
@乔焜
@乔焜 3 жыл бұрын
very helpful
Linux/Mac Terminal Tutorial: How To Use The cURL Command
8:58
Corey Schafer
Рет қаралды 201 М.
Linux/Mac Terminal Tutorial: How To Use The find Command
17:45
Corey Schafer
Рет қаралды 195 М.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text
37:55
Where GREP Came From - Computerphile
10:07
Computerphile
Рет қаралды 944 М.
Regular Expression Basics
36:59
Jason Wertz
Рет қаралды 134 М.
Filtering .log files, with cat, grep, cut, sort, and uniq
15:36
Linux Crash Course - The find command
25:56
Learn Linux TV
Рет қаралды 91 М.
EVERYONE Needs to Learn a Little Bit of AWK!
16:29
Gary Explains
Рет қаралды 400 М.
Awk: Hack the planet['s text]! (Presentation) - 2023 Update
1:07:40
Benjamin Porter
Рет қаралды 21 М.
18 Commands That Will Change The Way You Use Linux Forever
29:50
Akamai Developer
Рет қаралды 1,3 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН