AWK, SED, PRINTF?!? (Linux+ Objective 1.2.2)

Sdílet
Vložit
  • čas přidán 27. 08. 2024
  • Manipulating text is one of the things the Linux command line is really, really good at doing. Using a combination of tools, you can pretty much get any sort of formatted output from pretty much any sort of text input. In this video, we learn to use "awk", "sed", and "printf" to transform text.
    This is part of our CompTIA Linux+ series, but is a good primer on using these tools whether you're prepping for the exam or not.
    The Linux+ objectives are available here: snar.co/plusob...
    If you'd like to look at our "Weekend Assignment", even if it's after the fact, the challenge should still be available here: snar.co/wa1
    We'll go over the solution at the beginning of this week's livestream. (I'll try to remember to put a link to the stream right here afterward)
    ALSO: My "other" channel, with no rules and lots of... me, is over here:
    ‪@brainofshawn‬
    I mentioned my Patreon page, which is here:
    / shawnp0wers
    And if you just can't get enough of the stuff I do, or you want to connect with other Nerdlings, most things are listed here: shawnp0wers.com
    Thanks for joining us!
    #Linux #CompTIA #XK0_005

Komentáře • 54

  • @mrigankaz
    @mrigankaz Před 3 měsíci +2

    Hello Shawn,
    An earnest request, kindly complete the Linux+ series if you can at your earliest convenience. I have scheduled my Linux+ in early August and I'm so thankful that I found your series. I'm following you content now for my preparation.
    Absolutely amazing series, thanks so much for publishing such a great content.

  • @ummulkheirnur1687
    @ummulkheirnur1687 Před 2 dny

    i am also preparing the linux+ through shawn's videos. we really appriciate your effort. thank you soo much 👍💯💫

    • @shawnp0wers
      @shawnp0wers  Před 11 hodinami

      My apologies for the big delay in finishing the course, but thank you for your kind words!

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

    Thank you very much for your videos, they are pretty few resources just for linux+, so these are really helpful. I just wanted to point out.
    The `-e` flag for sed is not for extended regular expressions but for "add the script to the commands to be executed"
    I don't what it means as inline sed is automatically processed without the flag but it isn't for extended regex (that's a -E flag)

  • @michaelbriseno7501
    @michaelbriseno7501 Před rokem +2

    Thanks Shawn! This is the series I needed! I have started studying for Linux+ and happen to stumble upon this series just in time! your explanations and examples are great! You make the material easier to digest and understand! Keep it up!

    • @shawnp0wers
      @shawnp0wers  Před rokem +1

      Thank YOU, that's great to hear! And hopefully with my silly 90days thing, I'll start pumping out content more frequently!!!

    • @dariusvlogs3634
      @dariusvlogs3634 Před rokem

      @@shawnp0wers is your series enough content to pass the linux + ?

  • @imtechfreak1800
    @imtechfreak1800 Před rokem +1

    And we have been waiting for it eagerly ! Thanks for being there for others like me

    • @shawnp0wers
      @shawnp0wers  Před rokem

      I appreciate the patience. Life sure does have a habit of getting in the way! :D

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

    Fantastic video Shawn!

  • @wallacenichols4232
    @wallacenichols4232 Před rokem +1

    Love your videos Shawn! Thank you for your hard work! Please consider doing a RHSA course ! PLEASE PLEASE PLEASE 🙂

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

      Thank you! It's one of the biggest requests I get, so... hopefully I'll finish Linux+ soon and move on to something new. Maybe RH!

  • @mason8714
    @mason8714 Před rokem

    awk seems good to use, sed and printf i may need abit more time to play around to get my head around - great video! great content!

    • @shawnp0wers
      @shawnp0wers  Před rokem +1

      Thanks! And yeah, I find AWK (and the specific use case I outlined) to be very useful. I occasionally use SED for things, but need to google it every time -- and I honestly very rarely use printf.

  • @HopliteSecurity
    @HopliteSecurity Před rokem +1

    Fantastic work && thanks a million Shawn, I was so glad to see this video in my feed!

    • @shawnp0wers
      @shawnp0wers  Před rokem

      Glad you enjoyed it! It feels *really good* when I can record and release a new video.

  • @italianbum
    @italianbum Před rokem

    This video was very helpful for my Linux+ exam

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

    I have been using Jasion Dion training courses for bootcamps etc etc. You are 10x more interesting man. With much less resources I think you could explode

  • @amanuelyohannes7151
    @amanuelyohannes7151 Před rokem

    Thank for preparing the assignment Shawn! That will help a lot.

    • @shawnp0wers
      @shawnp0wers  Před rokem

      I'm glad to hear it! I'm going to keep trying to come up with useful assignments, but we'll see how well I can do...

    • @amanuelyohannes7151
      @amanuelyohannes7151 Před rokem

      @@shawnp0wers You are already doing great! The last assignment was epic. I learned a lot from it.

  • @damianpodgorski6977
    @damianpodgorski6977 Před rokem +2

    Hi Shawn! Good to see a new video again! Congratulations on becoming a grandpa! I am planning on taking the Lpic-1 101-500 Exam next month so I am excited for a new challenge again. Maybe I will take a Linux + next year but it would be just for fun :)

    • @shawnp0wers
      @shawnp0wers  Před rokem +1

      w00t! Good luck on the 101-500!!!

    • @damianpodgorski6977
      @damianpodgorski6977 Před rokem

      @@shawnp0wers thanks man! Thank you for making this content ! I am planning to go for it on 14.10

    • @mason8714
      @mason8714 Před rokem

      @@damianpodgorski6977 let me know how you get on please. I want to take it at the start of next year.

    • @damianpodgorski6977
      @damianpodgorski6977 Před rokem

      @@mason8714 sure man! I can share some tips with you if you want

    • @mason8714
      @mason8714 Před rokem

      @@damianpodgorski6977 that would be fantastic! Are you on shaens discord?

  • @Duha_01
    @Duha_01 Před rokem +1

    This is actually c programming the printf function with formatting specifier

  • @mikeolear
    @mikeolear Před rokem

    Thanks Shawn! Ps... Thanks also for such inspiring podcasts!

    • @shawnp0wers
      @shawnp0wers  Před rokem +1

      Whoa, thank you AGAIN!
      I'm pretty excited about the silly 90days thing too, should get me in the groove of releasing videos without overthinking (as much). :)

  • @chillnacho
    @chillnacho Před rokem

    I'd love to see you do a more detailed video on awk.

    • @shawnp0wers
      @shawnp0wers  Před rokem

      No promises, but there's certainly plenty of material. AWK is... so powerful. :)

  • @mikes6688
    @mikes6688 Před rokem

    Thanks!

  • @scottb4029
    @scottb4029 Před rokem

    Good video Shawn. My brain had already exploded. I have tried to read the book on AWK by the authors of the language. Great book but dense. It is called, The AWK programming language by: Auru:o V. AHo BRIAN W. KERNIGHAN PETER J. WEINBERGER, I found it as a pdf online. Published in the 70S but still just as good as the day it was written. Thanks again for the video.

    • @shawnp0wers
      @shawnp0wers  Před rokem

      Thanks! Yeah, it was tough to decide an appropriate "depth" for each tool. Ironically, while AWK is probably the most complex and powerful, it was the one I chose to go least into. Still, my hope is that we covered enough for what the Linux+ might throw at someone. :)

  • @Tom-wm4gy
    @Tom-wm4gy Před rokem +1

    Shawn, you are a god!
    You rock my tiny little brain, again...!
    Many, many thanks!
    P.S. god with a capital "G" is not allowed..

    • @shawnp0wers
      @shawnp0wers  Před rokem +1

      Thank you! And I'm not even sure I qualify for lower-case "g" god, but for SURE not a capital! :D

    • @Tom-wm4gy
      @Tom-wm4gy Před rokem +1

      Thanks for your hard work!

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

    where is your other channel? you said you would post a link

  • @xammocoloniax
    @xammocoloniax Před rokem

    Thanks for this! One problem I'm looking into though --- { printf "%f
    " 43.7 } gives me invalid number!

    • @xammocoloniax
      @xammocoloniax Před rokem +1

      aaaaand I figured it out 10 seconds later --- I noticed my system is set up with commas for decimals, so 43,7 did the trick! heads-up to euroland.

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

    sed is like vi? cool

  • @rohanofelvenpower5566

    can you add padding to printf string on the Left AND Right side? so something like :
    printf "%10s
    " text
    will add 10 spaces padding to the LEFT side, but can you simulataneously add some space to the right as well?

    • @rohanofelvenpower5566
      @rohanofelvenpower5566 Před rokem

      actually dont mind, I just figured it as I typed the comment lol:
      printf "[%10s%-10s]" text
      [ text ]
      so if you give it one text argument any consequent %s you add in the formula will refer to the same outputted variable

    • @shawnp0wers
      @shawnp0wers  Před rokem

      I didn’t know the answer, so thanks for testing! :)

    • @rohanofelvenpower5566
      @rohanofelvenpower5566 Před rokem

      so heres some more shenningans. you can mix the %s and %d for the same variable! see my consequent comment:

  • @rohanofelvenpower5566

    printf "[%-10s]
    %s
    " here "not here"
    [here ]
    not here

  • @kenmurphy4259
    @kenmurphy4259 Před rokem +1

    The hair … 😂

  • @DanielTose
    @DanielTose Před rokem +2

    Why not just sed '/^#/d' instead of using 2 seds? That lets you keep some of the visual break ups for readability. The -e is extraneous there as well as you're only using one pattern at a time. The -e is for if you want to do two things. You can chain the -e without having to pipe to another sed:
    sed -e '/^#/d' -e '/^$/d' file.conf

    • @shawnp0wers
      @shawnp0wers  Před rokem +1

      I didn't realize you could chain two substitutions with one command, cool!
      And as far as why one way over another... it's always so challenging to decide what will make the basics easier to understand. Plus, I don't use sed often enough to make the best choices, truth be told. But thanks for the info -- I love when I get to learn stuff I didn't know! :)