Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
MalikMuaddibSoong@startrek.website to linuxmemes@lemmy.worldEnglish · 11 hours ago

An awkward realization

startrek.website

message-square
56
fedilink
296

An awkward realization

startrek.website

MalikMuaddibSoong@startrek.website to linuxmemes@lemmy.worldEnglish · 11 hours ago
message-square
56
fedilink
alert-triangle
You must log in or register to comment.
  • GreenKnight23@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    3 hours ago

    joke so dark I had to turn up my screen brightness to enjoy it.

  • cmgvd3lw@discuss.tchncs.de
    link
    fedilink
    arrow-up
    5
    ·
    4 hours ago

    You can even do sum with awk, you don’t need excel

    • tal@lemmy.today
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 hours ago

      num-utils has numsum.

  • Lauchmelder@feddit.org
    link
    fedilink
    arrow-up
    22
    arrow-down
    1
    ·
    6 hours ago

    Why spend 30 seconds manually editing some text when you can spend 30 minutes clobbering together a pipeline involving awk, sed and jq

    • GreenKnight23@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      3 hours ago

      TIL I am an OP wizard.

    • CheesyFox@lemmy.sdf.org
      link
      fedilink
      arrow-up
      7
      ·
      4 hours ago

      to be fair, out of those three, jq invokes the least existential dread in me

  • UltraBlack@lemmy.world
    link
    fedilink
    arrow-up
    8
    ·
    6 hours ago

    All my homies use dubious regex

  • Delilah (She/Her)@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    7
    ·
    7 hours ago

    Honestly I think 90% of people would never use awk if there was a simple preinstalled command for “print the nth column”

    • Laurel Raven@lemmy.zip
      link
      fedilink
      English
      arrow-up
      3
      ·
      2 hours ago

      This is definitely somewhere that PowerShell shines, all of that is built in and really easy to use

    • OpenStars@piefed.social
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      3 hours ago

      cut?

      • tal@lemmy.today
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        3 hours ago

        To be fair, a lot of the programs don’t use a single character, have multiple spaces between fields, and cut doesn’t collapse whitespace characters, so you probably want something more like tr -s " "|cut -d" " -f3 if you want behavior like awk’s field-splitting.

        $ iostat |grep ^nvme0n1
        nvme0n1          29.03       131.52       535.59       730.72    2760247   11240665   15336056
        $ iostat |grep ^nvme0n1|awk '{print $3}'
        131.38
        $ iostat |grep ^nvme0n1|tr -s " "|cut -d" " -f3
        131.14
        $
        
        • TechLich@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          56 minutes ago

          I never understood why so many bash scripts pipe grep to awk when regex is one of its main strengths.

          Like… Why

          grep ^nvme0n1 | awk '{print $3}'

          over just

          awk '/^nvme0n1/ {print $3}'

        • MalikMuaddibSoong@startrek.websiteOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 hour ago

          cut and tr are like the wonder twins of text munging

          Form of truncated whitespace! Shape of single whitespace! 😂

  • lime!@feddit.nu
    link
    fedilink
    English
    arrow-up
    11
    ·
    8 hours ago

    my favorite awk snippet is !x[$0]++ which is like uniq but doesn’t care about order. basically, it’s equivalent to print_this_line = line_cache[$current_line] == 0; line_cache[$current_line] += 1; if $print_this_line then print $current_line end.

    really useful for those long spammy logs.

    • OmnislashIsACloudApp@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      2 hours ago

      same, that statement saved me so much effort

  • Ŝan@piefed.zip
    link
    fedilink
    English
    arrow-up
    51
    arrow-down
    15
    ·
    edit-2
    10 hours ago

    Ok, þe quote misplacement is really confusing. It’s

    awk '{print $1}'
    

    How can you be so close to right about þis and still be wrong?

    • FiskFisk33@startrek.website
      link
      fedilink
      arrow-up
      1
      ·
      12 minutes ago

      I see what you did þere

    • MalikMuaddibSoong@startrek.websiteOP
      link
      fedilink
      English
      arrow-up
      16
      ·
      9 hours ago

      How can you be so close to right about þis and still be wrong?

      Honest answer: I’m sloppy on mobile

      Better answer:

    • hddsx@lemmy.ca
      link
      fedilink
      arrow-up
      13
      arrow-down
      1
      ·
      11 hours ago

      Who downvoted this? If you use awk, you know Sxan is using the correct syntax.

      • teft@piefed.social
        link
        fedilink
        English
        arrow-up
        28
        arrow-down
        4
        ·
        edit-2
        10 hours ago

        People have been downvoting him because he uses the letter thorn in his comments.

        Some people will hate on anyone different.

        • mexicancartel@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          10
          ·
          9 hours ago

          I recently noticed many people on lemmy have that thing rn. Why are they using it/is that autocorrecty thibgy or something? I didn’t downvote them but i hate seeing this. And it’s not just this letter

          • Badabinski@kbin.earth
            link
            fedilink
            arrow-up
            11
            ·
            8 hours ago

            I’m not using it because it would be extremely inconvenient for me, but I think that the English language deserves to have the thorn returned to it.

            • Possibly linux@lemmy.zip
              link
              fedilink
              English
              arrow-up
              1
              ·
              22 minutes ago

              Please no

              I have a hard enough time with English already

            • scathliath@lemmy.dbzer0.com
              link
              fedilink
              arrow-up
              3
              ·
              6 hours ago

              I used to use it for math notation, so I’d welcome it’s use again if I can keep using it as a placeholder for “then this happens” in between steps of functions.

            • teft@piefed.social
              link
              fedilink
              English
              arrow-up
              10
              arrow-down
              2
              ·
              8 hours ago

              The english alphabet needs to be completely redone. We should bring back thorn, eth, and wynn. We should also increase the vowels to actually represent the crazy amount of vowel sounds we have, dipthongs are dumb. 5 vowels is not sufficient for 15+ phonemes.

              • derfunkatron@lemmy.world
                link
                fedilink
                English
                arrow-up
                1
                ·
                2 hours ago

                Let’s capitalize nouns again while we’re at it.

          • somerandomperson@lemmy.dbzer0.com
            link
            fedilink
            arrow-up
            9
            arrow-down
            2
            ·
            9 hours ago

            It’s to confuse scrapers.

            • Gutek8134@lemmy.world
              link
              fedilink
              arrow-up
              10
              ·
              9 hours ago

              It’s going to be fun for etymologists 100 years from now

  • neuracnu@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    8 hours ago

    10 PRINT BUTTS

    20 GOTO 10

  • DreamButt@lemmy.world
    link
    fedilink
    English
    arrow-up
    18
    ·
    10 hours ago

    In all my years I’ve only used more than that a handful of times. Just don’t need it really

    Now jq on the other hand…

    • harsh3466@lemmy.ml
      link
      fedilink
      arrow-up
      6
      ·
      9 hours ago

      jq is indispensable

  • pelya@lemmy.world
    link
    fedilink
    arrow-up
    9
    arrow-down
    1
    ·
    9 hours ago

    Everything you do with awk, you can do with python, and it will also be readable.

    • NaibofTabr@infosec.pub
      link
      fedilink
      English
      arrow-up
      5
      ·
      edit-2
      4 hours ago

      Hmm, but you have to install and run the Python environment for that. AWK is typically present on *NIX systems already. Python seem like overkill for basic text processing tasks.

      • pelya@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 hour ago

        On Debian the python is preinstalled.

    • SkaveRat@discuss.tchncs.de
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      7 hours ago

      and perl, if you want it less readable

      • Possibly linux@lemmy.zip
        link
        fedilink
        English
        arrow-up
        1
        ·
        25 minutes ago

        Or you are old and crazy

      • Laurel Raven@lemmy.zip
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 hours ago

        Or PowerShell if you want it extra verbose

  • CubitOom@infosec.pub
    link
    fedilink
    English
    arrow-up
    17
    ·
    edit-2
    11 hours ago

    I’ve become a person that uses awk instead of grep, sed, cut, head, tail, cat, perl, or bashisms

    • SkaveRat@discuss.tchncs.de
      link
      fedilink
      arrow-up
      6
      ·
      edit-2
      7 hours ago

      I could try to learn awk while also trying to debug the annoying problem I’m trying to solve, orrr… cut and grep it is

    • OpenStars@piefed.social
      link
      fedilink
      English
      arrow-up
      13
      ·
      edit-2
      10 hours ago

      The stage of your degeneracy will involve learning PERL.

      Edit: one-liners FTW! 😁🐪

    • MalikMuaddibSoong@startrek.websiteOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      9 hours ago

      sort | uniq -c has entered the chat 🤣

  • otacon239@lemmy.world
    link
    fedilink
    arrow-up
    15
    ·
    edit-2
    8 hours ago

    I used awk for the first time today to find all the MD5 sums that matched an old file I had to get rid of. Still have no idea what awk was needed for. 😅 All my programming skill is in Python. Linux syntax is a weak point of mine.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      6
      ·
      9 hours ago

      Probably the very same thing that the post talks about, which is extracting the first word of a line of text.

      The output of md5sum looks like this:

      > md5sum test.txt
      a3cca2b2aa1e3b5b3b5aad99a8529074 test.txt
      

      So, it lists the checksum and then the file name, but you wanted just the checksum.

  • BarqsHasBite@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    11 hours ago

    What’s an awk?

    • This is fine🔥🐶☕🔥@lemmy.world
      link
      fedilink
      arrow-up
      24
      ·
      10 hours ago

      'awk tuah

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      18
      ·
      10 hours ago

      It’s a Linux command-line program (awk). It’s pre-installed practically everywhere, it’s very powerful for string processing, but it also uses a fairly complex syntax.

      As a result, not many people know how to really make use of it, but awk '{print $1}' is something you encounter fairly quickly when you need to get the first word in each line.

    • tofu@lemmy.nocturnal.garden
      link
      fedilink
      arrow-up
      14
      ·
      10 hours ago

      awkward

      • ratel@mander.xyz
        link
        fedilink
        arrow-up
        8
        ·
        edit-2
        7 hours ago

        That’s where they send you when the syntax drives you insane.

    • tal@lemmy.today
      link
      fedilink
      English
      arrow-up
      7
      ·
      10 hours ago

      https://en.wikipedia.org/wiki/AWK

    • SendMePhotos@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      10 hours ago

      awk yeah

    • driving_crooner@lemmy.eco.br
      link
      fedilink
      arrow-up
      3
      arrow-down
      12
      ·
      10 hours ago

      Amazon Web Keynotes. It’s a programming language for server administration.

      • Possibly linux@lemmy.zip
        link
        fedilink
        English
        arrow-up
        1
        ·
        24 minutes ago

        Wut

      • juliebean@lemmy.zip
        link
        fedilink
        arrow-up
        6
        ·
        7 hours ago

        uh, no.

  • h4x0r@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    11 hours ago

    I use gawk all the fucking time, if you spend a lot of time in a terminal or parse text often it is definitely worth the investment. It is a fantastic tool for both one liners and full scripts. The gawk manual is short enough to digest in a day or two.

    https://www.gnu.org/software/gawk/manual/gawk.html

    • bulwark@lemmy.world
      link
      fedilink
      English
      arrow-up
      5
      ·
      10 hours ago

      I remember when I first stumbled across this manual I was trying to look up a quick awk command and wound up reading the whole thing. It’s really one of the better GNU manuals.

  • mumblerfish@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    10 hours ago

    – [x] I’m in this picture and don’t like it.

linuxmemes@lemmy.world

linuxmemes@lemmy.world

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Hint: :q!


Sister communities:
  • [email protected]
  • [email protected]
  • [email protected]
  • [email protected]

Community rules (click to expand)

1. Follow the site-wide rules
  • Instance-wide TOS: https://legal.lemmy.world/tos/
  • Lemmy code of conduct: https://join-lemmy.org/docs/code_of_conduct.html
2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like “every user of thing”.
  • Don’t get baited into back-and-forth insults. We are not animals.
  • Leave remarks of “peasantry” to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn, no politics, no trolling or ragebaiting.
4. No recent reposts
  • Everybody uses Arch btw, can’t quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
5. 🇬🇧 Language/язык/Sprache
  • This is primarily an English-speaking community. 🇬🇧🇦🇺🇺🇸
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
6. (NEW!) Regarding public figures

We all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations.

  • Keep discussions polite and free of disparagement.
  • We are never in possession of all of the facts. Defamatory comments will not be tolerated.
  • Discussions that get too heated will be locked and offending comments removed.

 

Please report posts and comments that break these rules!


Important: never execute code or follow advice that you don’t understand or can’t verify, especially here. The word of the day is credibility. This is a meme community – even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don’t remove France.

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1.84K users / day
  • 4.19K users / week
  • 6.36K users / month
  • 19.9K users / 6 months
  • 1 local subscriber
  • 27.1K subscribers
  • 1.86K Posts
  • 93.8K Comments
  • Modlog
  • mods:
  • Kevin@lemmy.world
  • zephyr@lemmy.world
  • rtxn@lemmy.world
  • BE: 0.19.9
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org