grep: A Practical Guide

  Рет қаралды 70,158

Navek

Navek

5 ай бұрын

A quick guide on getting better with grep and its more popular uses.

Пікірлер: 158
@buysnoah
@buysnoah 5 ай бұрын
Who up grepping they file rn
@navekeng
@navekeng 5 ай бұрын
lol
@ekinakkaya9257
@ekinakkaya9257 5 ай бұрын
i'm grepping my log files so hard rn
@eklipsed9254
@eklipsed9254 5 ай бұрын
Noah?!!!!!
@buysnoah
@buysnoah 5 ай бұрын
@@eklipsed9254 ?
@chair547
@chair547 5 ай бұрын
When she grep on my file til I segfault
@amandasandell3351
@amandasandell3351 5 ай бұрын
now THIS is the kind of tutorial video i'd like to see more often. Straight to the point, no boilerplate, explain a concept and show an example. Very educational and useful
@navekeng
@navekeng 5 ай бұрын
Thanks! I appreciate it, more to come 😄
@leonardofralini6398
@leonardofralini6398 5 ай бұрын
No useless talks, great content with examples, good video and audio quality. Nice job! You earned a sub Keep it up!
@navekeng
@navekeng 5 ай бұрын
Tytyty 🫡
@diceandbricks
@diceandbricks 5 ай бұрын
I like how you focus on a single command and give a very helpful overview. So many other "10 great linux commands" videos don't give enough detail for me to retain them. This is much better.
@navekeng
@navekeng 4 ай бұрын
Much appreciated!
@TreeLuvBurdpu
@TreeLuvBurdpu 5 ай бұрын
-C is for context, a very important word.
@navekeng
@navekeng 5 ай бұрын
Yea haha just chugging through forgot the word ha
@NunoMartinsGalvao
@NunoMartinsGalvao Ай бұрын
Exactly is like the diff command where it says it has 3 lines of context (you can change the amount of lines of context). @navekeng great content btw
@monkeecrap
@monkeecrap 5 ай бұрын
You absolute gigachad. This was amazing, thank you. 🙏
@navekeng
@navekeng 4 ай бұрын
Glad you enjoyed it!
@abhishekvenkat9585
@abhishekvenkat9585 4 ай бұрын
Honesty I have known grep for like a decade and use it literally daily for half of that decade but watching this made me realise what all I was missing on. Thanks for the video.
@ericpayne2846
@ericpayne2846 5 ай бұрын
Excellent content. I hope you make a ton of videos this year. Thanks for sharing your knowledge!
@navekeng
@navekeng 5 ай бұрын
That's the plan! thanks!
@hasib927
@hasib927 5 ай бұрын
Really loved the video, very comprehensive yet quite short. Please keep posting more videos. Two useful flags that I would've love to see: -R and -n.
@navekeng
@navekeng 5 ай бұрын
good points, I didn't touch -n and I ended up cutting -R for time and brevity but there is a good point for its importance and should of figured out how to fit it in
@abneryang2102
@abneryang2102 4 ай бұрын
Just found this channel, great stuff. I really like the way you go about explaining stuff. Looking forward to looking through more of your content - keep going!
@navekeng
@navekeng 4 ай бұрын
More on the way, thanks!
@muhammedkadirtan3469
@muhammedkadirtan3469 5 ай бұрын
Came for the grep, stayed for the regex. Great content. One thing I would add is, sometimes I grep twice. For example, I want to find all the 404 logs, but then I also want to filter out logs with specific message, say "user not found". Then I can: cat server.log | grep 404 | grep 'user not found'
@navekeng
@navekeng 5 ай бұрын
Ah good point, Yea I guess it’s not obvious haha Thanks for watching!
@Hornet1806
@Hornet1806 5 ай бұрын
Pretty sure you can do both of those at the same time with -E and/or -v. Also, you can pass your file in to grep directly rather than cat, which is for concatenating files together. On some shells you can also just < file to print its contents.
@florianrose8907
@florianrose8907 2 ай бұрын
Please keep making those Videos. Those are so nicely done :) I am thankful!
@thewadegreen
@thewadegreen 5 ай бұрын
I subbed when he said "the alligators", hilarious! Loving the helpful video, it's great how you break everything down so well step by step.
@navekeng
@navekeng 5 ай бұрын
LOLOLOLOL Talking and typing is hard enough... to much to handle saying 'angle bracket' hahaha
@navekeng
@navekeng 5 ай бұрын
and of course thanks!
@Nobody-eg4bi
@Nobody-eg4bi 2 ай бұрын
You have the best video ever about grep on KZfaq
@niczoom
@niczoom 3 ай бұрын
Great video, thanks!
@danel1922
@danel1922 4 ай бұрын
such a great concise video, thx!
@jwf3148
@jwf3148 5 ай бұрын
I'm pressured for time, so I can't "Like" all of the positive comments - but please note that I do agree with each and every one...VERY userful videos...Yea for us, Thank you to you.
@ekinakkaya9257
@ekinakkaya9257 5 ай бұрын
straight to the point, also i really like the video & sound quality. you earned a subscriber brah
@navekeng
@navekeng 5 ай бұрын
ty ty 🫡
@INCLASKY
@INCLASKY 5 ай бұрын
Awesome videos for people learning man, keep it up!
@navekeng
@navekeng 5 ай бұрын
Glad you like them!
@HamsterLover1337
@HamsterLover1337 3 ай бұрын
Amazing!
@sagarchilivery6112
@sagarchilivery6112 5 ай бұрын
Trust me, you will grow like anything just keep posting linux videos! totally loving it!
@navekeng
@navekeng 5 ай бұрын
That's the plan!
@harijagarnauth
@harijagarnauth 5 ай бұрын
Awesome!
@navekeng
@navekeng 4 ай бұрын
Glad you think so!
@codeman99-dev
@codeman99-dev 4 ай бұрын
Very important note! The grep command is very battle tested. A regex that is safe with grep is not necessarily safe to use on requested resources. Always use extra caution with unknown inputs. Use extra extra caution if that unknown input can build a regular expression!
@jenselstner5527
@jenselstner5527 5 ай бұрын
Use 'grep -P' for Perl regexes. Then you're able to use special shortcuts like \d for a digit or \s for a whitespace, etc.
@navekeng
@navekeng 5 ай бұрын
Yea I avoided Peral because I think it adds complexity to what is necessary vs not, hell I was trying to avoid -E but then the command was so ugly lol my thought was the Perl folks already know how to do Peral regex! lol
@navekeng
@navekeng 5 ай бұрын
Thanks for the suggestion and watching!
@jsd4544
@jsd4544 4 ай бұрын
Useful! Thanks
@navekeng
@navekeng 4 ай бұрын
Glad you think so!
@JohnSmith-ni4cs
@JohnSmith-ni4cs 4 ай бұрын
@4:40 -e tells grep to search for the regular expression '-a'. It does not negate special characters. For example if you searched for -e 'a$' it would return lines ending with the letter a
@JairEmanuels
@JairEmanuels 5 ай бұрын
Great video, will definitely help me prepare for my exam :)
@navekeng
@navekeng 5 ай бұрын
Best of luck!
@NostraDavid2
@NostraDavid2 5 ай бұрын
RE: Logging Use structured logging and preferrably JSON - you can now use jq and do WAY more powerful stuff in an almost-as-complex language as regex.
@navekeng
@navekeng 5 ай бұрын
Yea that is true, I have a whole vid in the pipeline on OpenTelemetry (my day job is on an Observability team fun fact) But maybe I will do a quick video on jq, imo I use jq more then like awk. Thanks for the input, ill call you out when I do a vid on jq lol!
@abhishektiwari9561
@abhishektiwari9561 5 ай бұрын
this is a great short and to the point video.
@navekeng
@navekeng 5 ай бұрын
Appreciated!
@dandogamer
@dandogamer 5 ай бұрын
Need a video on jq , I'm a noob at it but can appreciate how efficient it can be to find and manipulate json
@navekeng
@navekeng 5 ай бұрын
No joke writing out a vid on jq right now!
@navekeng
@navekeng 5 ай бұрын
Sometime this week actually! Haha thanks for the comment
@TrustJesusToday
@TrustJesusToday 3 ай бұрын
It is helpful to get a grip on grep.
@tanuj05
@tanuj05 5 ай бұрын
Nice tutorial
@navekeng
@navekeng 5 ай бұрын
Glad you think so!
@Hornet1806
@Hornet1806 5 ай бұрын
Pretty sure -C is context. I use vim as my pager for man pages, but this should apply regardless. In man, I would use /^[ ]*-a, to find the section of the man page relating to the a flag. It reads, “show me lines beginning with some number of spaces immediately followed by -a”.
@navekeng
@navekeng 5 ай бұрын
good point, and yea I missed context lol
@kychemclass5850
@kychemclass5850 Ай бұрын
Thank you. If you have time a video on the $ sed command would be great, leading to string parsing.
@ShinichiroKururugi
@ShinichiroKururugi 4 ай бұрын
Great video! I consider myself a bit of a seasoned sysadmin but I still managed to learn '-w' and '-e' for the first time! I normally use 'fgrep " term " ' (or 'grep -F') to search literal strings. As a bit of feedback, I would avoid teaching 'cat | grep' as an example because it is generally considered to be poor practice as it achieves the same result while expending more CPU resources. But if you must use the example, then at the very least mention that it is less than an ideal use 'cat'. While 'cat' itself is not a huge deal resource-wise, myself, a long time ago have been guilty of using 'cat | grep' not knowing any better but hope to teach others better practices and better habits. I would instead use different commands like 'ifconfig' or 'ps' to demonstrate the use of piping into 'grep'.
@neunmalelf
@neunmalelf 5 ай бұрын
I guess that kind of videos can be helpful for beginner. Not too much detail and options digging, still a decent amount of helpful information. Well done! 👍☺
@navekeng
@navekeng 5 ай бұрын
Glad you enjoyed it! Yea the intention is showing the power, basically removing some unknown unknowns from someone newer or rusty with the tool!
@neunmalelf
@neunmalelf 5 ай бұрын
I wonder if people would be interested in KZfaq shorts with 'new / additional' tips and 'reminder' using this common tools 🤔.grep and find would be good candidates IMHO
@bl00dspec75
@bl00dspec75 5 ай бұрын
grep is probably one of the most powerful pieces of software ever created next to git
@navekeng
@navekeng 4 ай бұрын
agreed
@acayipbiseyya
@acayipbiseyya 3 ай бұрын
thx man
@friedrichmyers
@friedrichmyers 5 ай бұрын
This is what youtube videos should be like!
@navekeng
@navekeng 5 ай бұрын
Well don't think I can ask for a better complement! haha thank you!
@spamharder1757
@spamharder1757 5 ай бұрын
One useful flag I didn't see: the -o flag. I use it a lot when grepping by some regex pattern and I only need the match output
@navekeng
@navekeng 5 ай бұрын
Oh good callout I missed that and it would be a helpful one for sure!
@BarisGulten
@BarisGulten 5 ай бұрын
Good channel. Keep going 😊
@navekeng
@navekeng 4 ай бұрын
Thank you! 😃
@JassonCordones
@JassonCordones 4 ай бұрын
nothing that I didn't know already but great video anyways
@navekeng
@navekeng 4 ай бұрын
Glad you enjoyed!
@bermudi
@bermudi 5 ай бұрын
You should be using your pager to find things in manual pages. Usually `less` is used as man pager and literally all you have to do is press `/`
@navekeng
@navekeng 5 ай бұрын
Yea makes sense, I was mostly just demoing Gregs capabilities here but I could have been more clear it’s one of the ways to do it not “the” way. Thanks for watching
@surplusvalue3271
@surplusvalue3271 5 ай бұрын
super underrated
@navekeng
@navekeng 5 ай бұрын
Appreciate that!
@0xchilli
@0xchilli 5 ай бұрын
take the sub bro , u deserve it , will recommend u a lot
@navekeng
@navekeng 5 ай бұрын
I appreciate that!
@nikolaygruychev2504
@nikolaygruychev2504 5 ай бұрын
damn i did not know some of the flags. nice vid man
@navekeng
@navekeng 5 ай бұрын
Glad It was helpful, thanks for watching
@tieTYT
@tieTYT 5 ай бұрын
I've always thought "-C n" stands for context. As in, the number of lines of context around the match. At least, that's how I remember it.
@navekeng
@navekeng 5 ай бұрын
Ngl I made up contains clearly haha you are prob right I need to check the man page haha Thanks for the spot haha
@devondecenzo2658
@devondecenzo2658 4 ай бұрын
Wow; just found this and loved it! Thanks Navek, you know have a new Sub... ME :)
@navekeng
@navekeng 4 ай бұрын
Thanks and welcome
@jvdl-dev
@jvdl-dev 5 ай бұрын
I know this wasn't the point of your video, but when you're using `man` pages, usually your pager can perform searches within by pressing `/` while you're looking at the man page. For example `/` followed by `-D` and then pressing Enter will find the `-D` flag and then press `n` or `N` to search forwards and backwards. (You can also press `?` instead of `/` to start searching backwards. If you spend a lot of time in man pages, definitely worth figuring out the keyboard shortcuts :) Loved the video btw, very to the point, no unnecessary preamble, just pure usefulness.
@navekeng
@navekeng 5 ай бұрын
Yea good point and something I could have clarified that this was one way to do it not “the” way to do it! Thanks for the comment and watching!
@callisoncaffrey
@callisoncaffrey 5 ай бұрын
If you're using Gnu grep at least make use of the -P switch to get access to the Pearl regex. Also you could have mentioned that not all distros have --color added to the grep alias. Your IP regex isn't fully accurate either, since it also would match illegal addresses. Everything else was quite nice though. For coding purposes -Rn is useful (recursive and show line number). If you want to compare files I found it helpful to add the -x switch. I usually compared kernel .configs with grep -xivf old.config new.config, though I found that still needs too much scrolling, so I hope you have a gnu awk video ready, and you better not pipe grep into awk!
@MaxBerson
@MaxBerson 5 ай бұрын
6:00 C for "circa"!
@emilne83
@emilne83 5 ай бұрын
Great video overall. But I just want to point out that last part about filtering out IPs is wrong. The first 3 octets can all be 1-3 digits. That filter will miss a lot of possible IPs.
@arief_
@arief_ 5 ай бұрын
the nice thumbnail drag me here
@navekeng
@navekeng 5 ай бұрын
Weirdly enough this might be the best complement I have gotten, I try so hard and feel so damn bad at creating thumbnails. Honestly Linux is the easy part lol, Thanks!
@hj45lp
@hj45lp 4 ай бұрын
I suggest you watch next the fantastic "Where GREP came from" by Computerphile...
@navekeng
@navekeng 4 ай бұрын
A great video for sure
@carrion1234
@carrion1234 5 ай бұрын
what console font is that?
@navekeng
@navekeng 5 ай бұрын
JetBrains Mono Nerd Font
@carrion1234
@carrion1234 5 ай бұрын
@@navekeng oh damn, i use jetbrains mono in my jetbrains IDE, no wonder that tickled something in my brain :D thx!
@navekeng
@navekeng 5 ай бұрын
Haha idk it’s not perfect and I don’t love it exsactly yet, but can’t find something better. I’m sure it will change again 😆
@SamClegg
@SamClegg 5 ай бұрын
For `-C` the mnemonic is "context" I believe
@navekeng
@navekeng 5 ай бұрын
yea correct! hahaha I was flying through it and forgot what it was lol
@SamClegg
@SamClegg 5 ай бұрын
@@navekeng awesome videos by the way.. should have said that part first :)
@navekeng
@navekeng 5 ай бұрын
Thanks! Haha
@logangrosz6529
@logangrosz6529 5 ай бұрын
It may be worth nothing the globbing is performed by the shell, not grep. It is equivalent to just listing all the files that match the glob (because that's literally what the shell does).
@navekeng
@navekeng 5 ай бұрын
Yea, makes sense. Sometimes i zero in on how to use the tool and have to cut context. Its a balance for sure that I am still learning
@matthewrease2376
@matthewrease2376 4 ай бұрын
5:25 no, I don't believe the -- could relate to bash, that would have to be a feature of GREP itself. Because all arguments are passed the same way (argv). It would have to be GREP seeing the -- and handling it to change the behavior of future arguments.
@rabbitt1751
@rabbitt1751 4 ай бұрын
I’m pretty sure that “-“ is handled by libc, or more specifically getopt and getopt_long (both functions implemented in libc), which grep likely uses for parsing command line args.
@0xchilli
@0xchilli 5 ай бұрын
less, greater than are called angle brackets in this context 9:27
@navekeng
@navekeng 5 ай бұрын
LOL I was movinnn okay... grep makes my brain fog up and I prefer "big alligator" anyways
@patrickhawk6058
@patrickhawk6058 5 ай бұрын
grep -ril
@navekeng
@navekeng 5 ай бұрын
lol
@chyldstudios
@chyldstudios 5 ай бұрын
ripgrep > grep
@navekeng
@navekeng 4 ай бұрын
don't disagree, but you have to learn the rules before you can break them. Also you might not always be on a system that has ripgrep
@pabloqp7929
@pabloqp7929 5 ай бұрын
ripgrep®
@navekeng
@navekeng 5 ай бұрын
ripgrep is night and day better but you can't always guarantee you have access to it as an engineer on a remote system or lets say in a troubleshooting interview!
@hexssoulld
@hexssoulld 4 ай бұрын
Why use Grep? Reply with what you use it for!
@docmalitt
@docmalitt 5 ай бұрын
back to school kids... (btw just pumping your engagement, disregard the word salad coming out of my brai... "there is no spoon Neo"... keyboard)
@navekeng
@navekeng 5 ай бұрын
A keyboard warrior if you will, fightin the good fight
@MasterSergius
@MasterSergius 4 ай бұрын
Like who searched for this video using grep
@roganl
@roganl 5 ай бұрын
Clear screen is Ctrl-L .
@navekeng
@navekeng 5 ай бұрын
Somthing something “old habits” haha 😂
@nomandates9186
@nomandates9186 5 ай бұрын
video bookmarked
@navekeng
@navekeng 5 ай бұрын
🙂
@rabbitt1751
@rabbitt1751 4 ай бұрын
`grep EXP FILE` > `cat FILE | grep EXP`
@navekeng
@navekeng 4 ай бұрын
lol
@lylestavast7652
@lylestavast7652 5 ай бұрын
Been grepping since 1987 or so...
@navekeng
@navekeng 5 ай бұрын
🫡
@sense3d
@sense3d 4 ай бұрын
Great, but please speak more slowly.
@delqyrus2619
@delqyrus2619 5 ай бұрын
0:50 what a cat abuse.
@navekeng
@navekeng 5 ай бұрын
Lol
@LarsBahner
@LarsBahner 5 ай бұрын
We've been trying to get people stop doing cat |grep for years. Why on earth would you do that? You add another process to your pipeline for absolutely no other reason than adding unneeded complexity. You should probably think before you try to teach.
@mariusfacktor3597
@mariusfacktor3597 5 ай бұрын
I find myself needing to find a word in a directory and wanting to know the line number. -r for recursive, -n for line number grep -r -n searchterm dir/
@adriansrfr
@adriansrfr 5 ай бұрын
I find ripgrep to be faster and more useful, especially combined with fzf.
@ethernet764
@ethernet764 5 ай бұрын
Unlocking grep: Install ripgrep 😎
@navekeng
@navekeng 5 ай бұрын
“you must first know the rules, before you can break the rules” haha But yea if you are a power user there are many alternatives and ways to make it more powerful
@recarsion
@recarsion 5 ай бұрын
I use ripgrep btw
@navekeng
@navekeng 5 ай бұрын
ripgrep is night and day better but you can't always guarantee you have access to it as an engineer on a remote system or lets say in a troubleshooting interview!
@recarsion
@recarsion 5 ай бұрын
@@navekeng yep, unfortunately, but GNU grep is still a great tool
@ThePacolicious
@ThePacolicious 4 ай бұрын
Love your content and your presentation. Got a sub from this guy. | grep "earned sub"
@navekeng
@navekeng 4 ай бұрын
Thanks!
@nielsbom5558
@nielsbom5558 5 ай бұрын
Give it up for grep in 2024: ripgrep. It’s faster, it auto ignores files you probably don’t want to search for and it’s mostly a dropin replacement for grep.
@navekeng
@navekeng 5 ай бұрын
ripgrep is night and day better but you can't always guarantee you have access to it as an engineer on a remote system or lets say in a troubleshooting interview!
nmap: A Practical Guide
17:16
Navek
Рет қаралды 12 М.
Where GREP Came From - Computerphile
10:07
Computerphile
Рет қаралды 934 М.
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 86 МЛН
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 5 МЛН
Me: Don't cross there's cars coming
00:16
LOL
Рет қаралды 15 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 60 МЛН
Поиск файлов в Linux и Unix - find, grep, ack, ripgrep
7:02
Диджитализируй!
Рет қаралды 30 М.
Tmux has forever changed the way I write code.
13:30
Dreams of Code
Рет қаралды 928 М.
curl: A Practical Guide
16:13
Navek
Рет қаралды 26 М.
Become a shell wizard in ~12 mins
12:25
CODE IS EVERYTHING
Рет қаралды 228 М.
Xargs Should Be In Your Command Line Toolbag
16:24
DistroTube
Рет қаралды 96 М.
Why Use CAT Or GREP When You Can AWK?
11:13
DistroTube
Рет қаралды 76 М.
jq: A Practical Guide
14:54
Navek
Рет қаралды 11 М.
Первый обзор Galaxy Z Fold 6
12:23
Rozetked
Рет қаралды 141 М.
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 743 М.
Хотела заскамить на Айфон!😱📱(@gertieinar)
0:21
Взрывная История
Рет қаралды 6 МЛН
Easy Art with AR Drawing App - Step by step for Beginners
0:27
Melli Art School
Рет қаралды 8 МЛН