Another very cool use for grep is when using ps -ef to list all processes. You can grep to filter specific info like a process name, or user name. Pretty much any process. EG-You can use that to determine what the process ID number is of a specific process that isn't working properly in order to use kill -9 the process ID if it were giving you trouble and needed to be shutdown. For example: ps -ef | grep bash ps -ef | grep username etc.....
@birkner5104 жыл бұрын
You can also use pgrep for that.
@___91364 жыл бұрын
Yeah, pgrep is generally easier to use for this purpose. Did you notice that `ps | grep foo` returns at least two results, one of which is the grep process itself? pgrep doesn't have that problem.
@w01dnick4 жыл бұрын
3:05 why not to use recursive grep? "-R ." ?
@kellingc4 жыл бұрын
Thanks for posting this. Something a little different than tiling window managers et al. cat is actually for taking 2 or more files and catinating the output. So, sticking grep at the end of cat is perfectly fine. Or if you are looking to edit specific lines you can cat the file, use grep, and then use sed. Stick awk in there to the search ny a specific colum, then send it to lpr to print it out. The whole point of UNIX and Linux is streaming information, which is how the command line is set up. MS-DOS is the same way, with less utilities already available. You'd have to write a program to do things like grep, awk, and sed.
@HeikoRehm4 жыл бұрын
DT - The Human Manpage! Love it!
@birkner5104 жыл бұрын
Not using more commands or programs than necessary is not really important for use on the command line. But it is useful in scripts, as it potentially reduces dependencies and runtime.
@zizzu5494 жыл бұрын
Now 40hours tutorial on advanced regular expressions thanks.
@DistroTube4 жыл бұрын
Regular expressions shouldn't require a 40-hour series of videos.
@zizzu5494 жыл бұрын
@@DistroTube Regular expressions for turtles!
@theemacsen15184 жыл бұрын
@@DistroTube I think he was joking XD
@AnzanHoshinRoshi4 жыл бұрын
Thank you, Derek.
@anirbankopty9418 Жыл бұрын
It would have been really nice if grep output had the matching part colored in the video, I do have that for some reason which helps me.
@MrZombieSwamp4 жыл бұрын
you could've used grep --color=auto for better visualization
@enderger53084 жыл бұрын
Can you do a video/stream where you let your viewers send in links to their dotfiles to be critiqued by you? It would help highlight good and bad practices found in such files.
@AndersJackson6 ай бұрын
-A After -B Before -C Context To see a full expansion will make it easier to remember the shot options. "cat | grep" make it hard to see which lines in which file that are matched with grep. If you do grep on many files. That is why it usually are better to not concatenate (cat is short for concatenate) file and then pipe it into global regular expression print command (and grep is short for Global Regular Expression Print, which is what grep do).
@nacthewatcher4 жыл бұрын
Hey DT, regarding streaming cat into grep because you just used it, the better way is writing the grep command and pressing alt-. To bring the argument from the previous command.
@mrmiyagi54 жыл бұрын
I use the The Silver Searcher at work almost daily.
@w01dnick4 жыл бұрын
Same, switched to ag in almost all tasks. Still grepping logs.
@zeocamo4 жыл бұрын
you should use ripgrep, it is a FAST grep, so much faster ... and used with fzf ,,, it give you a fuzzy search in term or VIM
@jeetadityachatterjee69954 жыл бұрын
Do you plan on doing a video on text manipulation in the command line? I have touched on it using sed but I realise it's the tip of the iceberg
@cattmampbellvideo4 жыл бұрын
This was so helpful! Would you consider making a video on Regular Expressions? Thanks!
@genkiferal71782 жыл бұрын
I'd like o see the top 10 **useful** RegEx that the average person would use - not what a dev would use.
@crwmike04 жыл бұрын
The "command line snobs" would also tell you that cat is not for displaying files.
@FreeMan-wz3hj4 жыл бұрын
It's not, use less
@PestisNonSapien_GMO_exHuman4 жыл бұрын
vim is for newbs. cat is my editor cat
@CreachterZ4 ай бұрын
No I wouldn’t.
@CreachterZ4 ай бұрын
@@PestisNonSapien_GMO_exHuman. Newbie. I use a magnetized needle.
@IsaacAM-x9k Жыл бұрын
can you help me with this: You have not completed this task. You can use the cd command to navigate to the /home/analyst/logs directory and the grep command to return all lines containing the text string. To return all lines containing the text string, you must enter grep, then the string you are searching for, and then server_logs.txt. ?
@EdHatesNoobTubers Жыл бұрын
Great video, but man it bugs me the audio is not synced
@rohitmeharcse97722 жыл бұрын
Count the number of words in the file which contain all the letters a,e, i, o, u. These letters may occur more than once & other letters are also permitted. hellow you are so good can you solve this question pls
@shiftyworks56304 жыл бұрын
why not awk?
@DistroTube4 жыл бұрын
There is a progression to these things. First, a video on grep, then a video on sed, then a video on awk. Gotta walk before we run. ;)
@mramosch2 жыл бұрын
When you wc -w some text of exactly 1000 words you get 1000 as a result. However when you split the same text with grep into individual words you get 1040 words because grep is splitting off the ‘s and ‘t from words like • he’s • there’s • don’t • won’t • etc. when you do • cat input_file | grep -oE '\w{1,} ' Is there a way to make grep behave like wc, or do we have to use a different strategy for getting the right (desired) result? Any ideas?
@dlgang4 жыл бұрын
cool, I was thinking about grep the other day, no joke
@DistroTube4 жыл бұрын
Yea, sometimes I'm just sitting around and all of a sudden "grep" pops into my head. ;)
@hakumaou59294 жыл бұрын
google reads minds...creepy...
@letsplayonlinux43834 жыл бұрын
Great topic
@jahnuchoudhury66773 жыл бұрын
It's really great .. I really liked the you teach ..thanks ... Could you make some video on TCL ?
@UnlucksMcGee4 жыл бұрын
cat myfile | grep rickroll | wc - l Or just: grep -c rickroll myfile :D
@davidgomez794 жыл бұрын
command line snobs.. now I know how to describe them.
@folksurvival3 жыл бұрын
He was talking about Luke Smith.
@davidgomez793 жыл бұрын
@@folksurvival I figured as much. I feel the same way about Luke and a lot more. Way overrated. Pretty arrogant for a such a non advanced user.
@enoughmuskspam24904 жыл бұрын
A piece of advance ta anyone watching this video just use ripgrep instead it's better in every possible way.
@williamdroz68904 жыл бұрын
Hello fellow Rustacean :)
@PestisNonSapien_GMO_exHuman4 жыл бұрын
My favorite grep function acts like sed. Extract a substring from a line that contains a string that doesn't have to be part of that substring. echo -e "now is the time for all good"|grep -Po "the \K.*?(?= for)" grep -Po "wlan0.*inet \K.*?(?=/)"
@zacharycarbon43124 жыл бұрын
did you do what i think you did? was that a masterfully subtle rickrolling @1:06 ... was this whole thing a rickroll ?
@DistroTube4 жыл бұрын
Well, if you are using my bashrc, all you need to do is type "rr" for the terminal rickroll. ;)
@eherrmann014 жыл бұрын
I'm not sure if I'm amused or disturbed that he has rickroll on his .bashrc.
@GreyDeathVaccine4 жыл бұрын
grep -r "phrase" some dir - search recursively :-)
@luaumoal4 жыл бұрын
Take a look at ripgrep
@zweitlander8744 жыл бұрын
:)
@FranksThemen4 жыл бұрын
Grep is full of bloat and clearly violates the Unix philosophy. Instead of doing only one thing right, it does also read files and count lines. Worse feature creep than SystemD.
@justawfulgamer77384 жыл бұрын
Am I the only one that finds it odd that he doesn't look at the camera?
@stephenjones86454 жыл бұрын
He’s discussed that before. The room is too small to accommodate putting the dslr camera/tripod in front of him so he has to put it on the side.
@asswhole41954 жыл бұрын
First
@ikichullo4 жыл бұрын
Woah you're so cool i wish i could be like you wow you're so hip man i'm jealous you're so cool
@asswhole41954 жыл бұрын
@@ikichullo haha, thanks man. It gets lonely at the top sometimes though.
@a_maxed_out_handle_of_30_chars4 жыл бұрын
Nice, don't forget to put this in your resume, it really helps :)
@asswhole41954 жыл бұрын
@@a_maxed_out_handle_of_30_chars Already got that covered.
@DistroTube4 жыл бұрын
You guys are being really mean to Mr. Whole. He was just excited. The last 15 times he claimed "first" he was really the second. :D