I thought I’ll make this thread for all of you out there who have questions but are afraid to ask them. This is your chance!

I’ll try my best to answer any questions here, but I hope others in the community will contribute too!

  • Godort@lemm.ee
    link
    fedilink
    arrow-up
    4
    ·
    5 months ago

    Maybe not a super beginner question, but what do awk and sed do and how do I use them?

    • mumblerfish@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      5 months ago

      This is 80% of my usage of awk and sed:

      “ugh, I need the 4th column of this print out”: command | awk '{print $4}'

      Useful for getting pids out of a ps command you applied a bunch of greps to.

      ”hm, if I change all ‘this’ to ‘that’ in the print out, I get what I want": command | sed "s/this/that/g"

      Useful for a lot of things, like “I need to change the urls in this to that” or whatever.

      Basically the rest I have to look up.

    • neidu2@feddit.nl
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      5 months ago

      Probably a bit narrow, but my usecases:

      • awk: modify STDIN before it goes to STDOUT. Example: only print the 3rd word for each line
      • sed: run a regex on every line.