Linux Crash Course - The grep Command

Sdílet
Vložit
  • čas přidán 29. 06. 2024
  • The "Linux Crash Course" series (formerly known as the "Linux Essentials" series) tackles important concepts around Linux, one video at a time. In this video, Jay goes over the basics of the grep command, along with some useful examples.
    Thanks to Linode for supporting this video!
    - Check out Linode and get your very own Linux server ➜ learnlinux.link/akamai
    Support Learn Linux TV
    Note: Commission may be earned for any and all links presented here.
    - Support me on Patreon and get early access to new content! ➜ learnlinux.link/patron
    - Check out jay's latest book, Mastering Ubuntu Server 3rd Edition ➜ ubuntuserverbook.com
    - Affiliate store for Linux compatible hardware/accessories ➜ learnlinux.link/amazon
    - Check out the Tiny Pilot KVM for your Homelab ➜ learnlinux.link/tinypilot
    Time Codes
    00:00 - Intro
    00:38 - Check out Linode and get your very own Linux server!
    01:58 - What is "grep"?
    03:12 - Piping the cat command into grep
    03:58 - How to omit a search string
    04:49 - Running grep by itself
    05:32 - Using grep against a sample file
    07:33 - Showing line numbers with results
    08:00 - Additional options with the grep command
    10:06 - Using grep against multiple files
    10:55 - Recursive search with grep
    Blog article for this video:
    www.learnlinux.tv/linux-essen...
    Full Courses from Learn Linux TV
    • Linux Essentials Certification Workshop ➜ learnlinux.link/lpi-course
    • Linux Crash Course series ➜ linux.video/cc
    • Learn how to use tmux ➜ linux.video/tmux
    • Learn how to use vim ➜ linux.video/vim
    • Bash Scripting Series ➜ linux.video/bash
    • Proxmox VE Cluster Full Course ➜ linux.video/pve
    • Learn Ansible ➜ linux.video/ansible
    Linux-related Podcasts
    • Enterprise Linux Security ➜ enterpriselinuxsecurity.show
    • The Homelab Show ➜ thehomelab.show
    Learn Linux TV on the Web
    • Main site ➜ www.learnlinux.tv
    • Community ➜ community.learnlinux.tv
    • Enterprise Linux Security Podcast ➜ enterpriselinuxsecurity.show
    • The Homelab Show Podcast ➜ thehomelab.show
    • Content Ethics ➜ www.learnlinux.tv/content-ethics
    • Request Assistance ➜ www.learnlinux.tv/request-ass...
    Disclaimer
    Learn Linux TV provides technical content that will hopefully be helpful to you and teach you something new. However, this content is provided without any warranty (expressed or implied). Learn Linux TV is not responsible for any damages that may arise from any use of this content. The person viewing Learn Linux TV's content is expected to follow their best judgement and to make their best decisions while working with any related technology. Always make sure you have written permission before working with any infrastructure. Also, be sure that you're compliant with all company rules, change control procedures, and local laws.
    #Linux #LinuxTutorial #grep
  • Věda a technologie

Komentáře • 79

  • @TradersTradingEdge
    @TradersTradingEdge Před 2 lety +24

    Love these series Jay, thanks very much.
    What I really appreciate in your videos is, that you explain the meaning/naming of options in the commands. For example "-r" for "recursive" ,or "-i" for "insensitive". This helps very much to memorize these options, because they are endless when it comes to shell commands ;-) Keep up your great work Jay, thanks.

  • @Ladida455
    @Ladida455 Před 2 lety +11

    I´d love to see a episode on advanced grep use-cases. I´m often supprised how powerful and useful this little application is.

  • @d00dEEE
    @d00dEEE Před 2 lety +5

    Jay, next week do "How to do your taxes with the 'find' command!" 😁 'find' has soooo many options that it probably requires 3-4 videos...

  • @mikegropp
    @mikegropp Před 2 lety +6

    Often the reason people use the format "cat file.txt | grep term" is because they want to search for multiple terms separately. I can can tap the up arrow to get the previous command then easily change "term" since it's at the end of the command where the cursor will be. For a command in a bash file, I would use "grep term file.txt" to keep it shorter.

  • @theunclemez
    @theunclemez Před 2 lety +2

    Hello Jay
    only to say thank you so much for this video
    i'll watch it like a good dozen of times
    you actually realized an old dream that even books wasn't able to make possible
    Stay blessed and I stay tuned

  • @TheCodeAlwaysWins
    @TheCodeAlwaysWins Před 8 měsíci

    Needed a refresher and this was a great/concise overview

  • @rileyf9462
    @rileyf9462 Před 8 měsíci

    great video and great content. production was there and I am excited to keep using your short and specific videos to help me further my understanding of terminal thank you for doing this.

  • @BrianKismetDesign
    @BrianKismetDesign Před 2 lety

    Thanks Jay. I never looked at the man page because I tend to use find, but you explained it very clearly. Grep demystified! I'll be using it a lot more now.

  • @user-fe3hw5ej8q
    @user-fe3hw5ej8q Před 6 měsíci

    Thank you for this! I didn't need to take notes because your way of teaching made it so easy to learn and remember for future application.

  • @jmlc11
    @jmlc11 Před 2 lety +5

    I also use -l to list only the filenames which contain the search term. and also zgrep for when the files are compressed. Great video!

    • @d00dEEE
      @d00dEEE Před 2 lety +3

      And pgrep to look at processes...

  • @duamalik4645
    @duamalik4645 Před 8 měsíci

    your videos are super helpful, I appreciate your work.

  • @chrisa.1740
    @chrisa.1740 Před 2 lety +2

    Excellent tutorial! I've only used `grep` by looking up examples, but now I'll try and use it from scratch like your examples. This video was well formatted and informative, thank you.

    • @seanfaherty
      @seanfaherty Před 2 lety +2

      I usually run one terminal with what I’m doing and another with the -h dialogue or the man pages. Grep -h or man grep

  • @onuronel8319
    @onuronel8319 Před rokem +1

    THAT IS A INCREDIBLE TEACHING WORK, THANK YOU VERY MUCH.

  • @olafhuerta2318
    @olafhuerta2318 Před 2 lety +1

    Great video 👏🏻

  • @bahathir_
    @bahathir_ Před 2 lety +2

    Corrections for "-c" option.
    "-c, --count print only a count of selected lines per FILE.."
    So if there are 2 or more occurances in a line, it count as 1.
    Thank you.

  • @georgehope5477
    @georgehope5477 Před rokem

    Super cool, very useful, thank you very much.

  • @Bubbasaure92
    @Bubbasaure92 Před měsícem

    Thank you so much this really helped with completing my assignment

  • @Mythologos
    @Mythologos Před 2 lety +3

    Grep is what got me into Unix, it is hands-down my #1 favorite program ever written, I use it for everything! If I hadn't found grep I'd probably still be using Linux like Windows, it opened up a whole world for me.

  • @oskar3514
    @oskar3514 Před 2 lety +8

    Good one Jay. Thanks for the detailed examples. The grep -ri is very powerfull and I'll be using it many times...

    • @d00dEEE
      @d00dEEE Před 2 lety +1

      Do 'which rgrep', and if it exists, it's the equivalent of 'grep -r' without having to do as much typing (yeah, yeah, you're only saving 0.002 seconds, but it's easy to remember, too 😀).

    • @xrafter
      @xrafter Před 2 lety +2

      @@d00dEEE
      اكيد

  • @techsavvyscruz
    @techsavvyscruz Před 4 měsíci

    Awesome . Thanks man

  • @4thatfilm
    @4thatfilm Před 4 měsíci

    @11:05 I love it how Jay gets irritated with us asking a rhetorical question. I've seen other video instructors do this too. It must be frustrating after a while making these videos ...labors of love... and why aren't you people getting this!?!?

  • @volkervitt
    @volkervitt Před 2 lety

    After using grep the non-optimal way I finally learned how to do better. Thanks for the video.

  • @keithmiller9665
    @keithmiller9665 Před 2 lety

    Good video. Thank You!

  • @likithr.n9692
    @likithr.n9692 Před rokem

    Amazing explanation

  • @nkmicros540
    @nkmicros540 Před 2 lety

    I use "grep" for a couple of years now and did not know I could use it individually, without pipping it as with "cat", "less" or so...
    This command is more powerful than I was thinking =)

  • @bw_merlin
    @bw_merlin Před 2 lety

    This was great.

  • @brpawankumariyengar4227
    @brpawankumariyengar4227 Před měsícem

    Thank you very much ….very useful Video

  • @YannMetalhead
    @YannMetalhead Před měsícem

    Good video!

  • @PS_Tube
    @PS_Tube Před 2 lety

    Your videos are gem Jay. Thank you.

  • @yvanvogel6401
    @yvanvogel6401 Před 2 měsíci

    Thanks a lot !

  • @dhawang.gayash4080
    @dhawang.gayash4080 Před 2 lety

    Jay looks great fashioning that beard. Kudos bro!!

  • @jbuddyman
    @jbuddyman Před rokem

    Thanks for sharing

  • @pfeffi030
    @pfeffi030 Před 11 měsíci

    loving the Mr. Rogers Sticker 🙂

  • @shannonbrookshire234
    @shannonbrookshire234 Před 9 měsíci

    awesome video

  • @joffreybluthe7906
    @joffreybluthe7906 Před 2 lety

    I started watching your channel a few days ago, and I saw some earlier ones before this one. Funny enough, it seems to me like you look younger now than you used to, I think it's because you used to wear glasses and no beard ^^
    Anyway thx for the tips! I'm a big fan of the grep command :)

  • @fmj_556
    @fmj_556 Před 2 lety +1

    Your vid’s are awesome! Thanks!!!

  • @hitthetraget8233
    @hitthetraget8233 Před 3 měsíci

    i love that samus is now a "bounty hunger". they must really like bounties huh.

  • @azizmili3800
    @azizmili3800 Před rokem

    you are our super hero thank you

  • @DmitryStepanov-mo6wt
    @DmitryStepanov-mo6wt Před 11 měsíci

    thanks for guide❤

  • @ironmanlifts
    @ironmanlifts Před 2 lety +2

    Hey Jay, thanks for the videos. Funny you mentioned the grep command cause today I looked up how to print everything and highlight the results. ifconfig | grep -e "^" -e "192.168". Actually stopped by to see your kubernetes videos. Don't know much about it so looking to learn more. Rocking that beard. 👊👏

  • @SunsetGraffiti
    @SunsetGraffiti Před měsícem

    Your character list proves we are of the same creed. Hello, brother.

  • @YuriySamorodov
    @YuriySamorodov Před 11 měsíci +1

    Isn't pipe slows slowing down execution? In case of cat | grep bash should first get contents of the file and then pipe the whole contents to grep.
    Perhaps grep would run cat under the hood first though...

  • @stefanomarini8468
    @stefanomarini8468 Před 2 lety

    The best teacher ever, thank you!

  • @anandbvs143
    @anandbvs143 Před rokem

    ❤ excellent

  • @garimasingh8530
    @garimasingh8530 Před 2 měsíci

    Thanks

  • @aaronperl
    @aaronperl Před 2 lety +3

    Are you planning to do (or have you done in the past?) an intro to regular expressions? That's where the real power of grep (and several other unix/linux tools) is. Please realize I am not criticizing the lack of regex in this video; introducing the basics of grep is complex enough as it is :)
    I love regular expressions, I use them all the time. But I always had trouble when I was teaching, trying to get people to really understand what they do and why they're useful. And the syntax is.... not always obvious, even when you're familiar with it.
    This is good series. Although I already know most of these myself ( _not_ a criticism! :) we were all beginners at some point), I have learned a few things along the way, and I think these videos serve as a good introduction to the tools that are available for those just getting started, or who may have avoided the command line in the past.

  • @yaserfazel4839
    @yaserfazel4839 Před rokem

    thank you

  • @jackal6902
    @jackal6902 Před měsícem

    You got your like ;)

  • @Andrii87
    @Andrii87 Před 5 měsíci

    Tutorial starts at 2:00

  • @toylemmons9320
    @toylemmons9320 Před měsícem

    TY

  • @Joey_Tai
    @Joey_Tai Před měsícem

    Great video. I have a question. How do you build this command prompt?

  • @samirfighter1213
    @samirfighter1213 Před 2 měsíci

    thnx

  • @srsr6099
    @srsr6099 Před 2 lety +1

    Jay can we ask for shell-customization video

  • @MOHAMEDSOLIMAN-py7kl
    @MOHAMEDSOLIMAN-py7kl Před 7 měsíci

    thank u

  • @xhulioberberi7823
    @xhulioberberi7823 Před 2 lety

    Please make one tutorial for configuring coTurn in NextCloud Talk.

  • @DouggieDinosaur
    @DouggieDinosaur Před 2 lety

    Great video - great sponsor too - Linode is what I've been needing for years (sick of PLESK).

  • @kychemclass5850
    @kychemclass5850 Před 2 lety

    Huion (Graphics tablets) don't make Linux drivers.
    Kernel hardware support isn't perfect as pen position and where pixels appear on screen are offset.
    Offset is rectified by doing
    $ xinput
    and manually reading the ID when you see a line like...
    Tablet Monitor Pen Pen (0)
    which is escorted by the tabbed value "id=20"
    This id number is used with data from the $ xrandr command
    which gives the name of the Graphics tablet. My $ xrandr command gave the tablet the name of "HDMI-1"
    Then you do
    $ xinput map-to-output 20 HDMI-1
    to correct the offset.
    Your explanation of grep has moved me one step closer to automating the process
    (p.s. the ID number changes when I use a different graphic tablet, 20" or 16") grep will help me make run a script that can read the current 'id' number and the 'name' to automatically run the map command.
    Thank you so much Jay. Much appreciated.

  • @porcellinoveille
    @porcellinoveille Před rokem

    Thx so much teaching I.T. and english also lol

  • @jd5274
    @jd5274 Před 3 měsíci

    nICE FF6 Reference!

  • @RDH.85
    @RDH.85 Před rokem

    Can someone answer this question please? How do you copy and paste the text file from the blog post back into the nano text editor in the Linux command line? Thx

  • @tazaccking7467
    @tazaccking7467 Před rokem

    sir I am using redhat in virtual box and i want to connect my windows host machine to redhat ansible. is it possible ??

  • @shishirkrishna2772
    @shishirkrishna2772 Před 10 měsíci

    I have a question, in a folder there are 1000's of files where I need to search for two words which is not in a single sentence but is in a single file. So how can I use the grep command

  • @juantv9331
    @juantv9331 Před 10 měsíci

    Can you please analyze this. Question? I am eager to learn. Thank you very much.
    For instance, given the following command:
    ls --help | grep "dired"
    Answer Format:
    Look to the logs file and filter the specific string which starts with CTK?
    CTK{*****************************************}

  • @idoeini429
    @idoeini429 Před 4 měsíci

    I need help. I try to display lines with grep “/page1”.
    But in addition to “/page1” it displays “/page10”, “/page12”, “/page16”… etc.
    I need “/page1” only. How do I do that?

  • @SathwikTS-xh9vf
    @SathwikTS-xh9vf Před 8 měsíci

    is there anything which will help me open that file and point to it instead of just printing that given line
    ??

  • @PoseidonsRage21
    @PoseidonsRage21 Před 2 měsíci

    What I'm trying to figure out is. how do I isolate negative numbers, I've tried
    $ grep -e -$ file
    But it comes up with nothing.
    There're 5 lines with negative numbers that I have to isolate, but I can't figure out how to

  • @RalphNgOfficial
    @RalphNgOfficial Před rokem

    Can I use grep to find for a file ?

  • @melwinsebastian6384
    @melwinsebastian6384 Před rokem

    How to search for whitespace using grep

  • @williambaldwin9346
    @williambaldwin9346 Před 2 lety

    Terra should be Esper/ Human ;)

  • @xrafter
    @xrafter Před 2 lety

    grep is a grep.

  • @xLuminary
    @xLuminary Před rokem +2

    please fix your pictures in the background they are not equidistant. My disappointment is immeasurable and my day is ruined

  • @abnow1998
    @abnow1998 Před rokem

    Before running any command, you should have shown that file contents and then could have explained by using grep we can extract / filter out this text from this, poor explanation