Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    It is suggested to run ip addr twice ( it might take too long , it might not be idempotent ) when we can just capture the output to a variable and then reuse that output. Commented Sep 11, 2024 at 8:49
  • Made a typo "It is suggested" == "It is not suggested" Commented Sep 11, 2024 at 19:27
  • Eh, @Prem, there are many things wrong with this answer. It's hacky and inelegant. Sure, I could use a variable or a tmp file, but given how quickly the command runs, it didn't seem worth it. As for idempotency, the first run only gives us the headers, and those don't change as they don't depend on the actual values being returned as far as I know. Commented Sep 12, 2024 at 9:35
  • (1) I was talking about the general cases , where we can (must) avoid running the same command twice [ Eg1 when updating some DB table + Eg2 Downloading some large content ] just for formatting purposes. While that change is almost trivial , it will make the Solution a little bit better , not worse. Hence I mentioned it. (2) Yes , in addition to that , there are quite a few things wrong here [ Eg3 using jq & Perl when Perl itself will do + Eg4 making sure the columns are visibly aligned ] though those changes are not really trivial , hence I did not mention those earlier. Commented Sep 12, 2024 at 10:44
  • 1
    @Prem I know. That's why I started this answer with "Here's a horrible, clunky, hacky workaround". Commented Sep 12, 2024 at 11:06