News for hackers. Stuff that matters.
Re:What does $0=$2 in awk do? by LanternLight83 on Sunday September 25, 2022 @07:23PM (#32977512)
I think awk and sed are great, and it's great to eschew pipes when a powerful component that's ready in the pipelibe, like sed, awk, or grep, can pull double duty, but do think that one should favor using `grep -e` with a positive look behind in a case like this. I can just picture an innocuous string being added anywhere above the version string and throwing this one-liner off, when a regex could have pulled the version string out from an arbitrary position within the file and would hold up much more robustly; You don't want to impose opaque constraints on future edits even if you're the only one who will be editing the file, it's just too easy to forget and trip over later.
Re:What does $0=$2 in awk do? by jrm4 on Sunday September 25, 2022 @07:54PM (#32977743)
I'm whatever the opposite of a code golf extremist is.

E.g. I hate the so called "useless use of cat." I uselessly use cat all the dang time; visualizing the pipeline is infinity more useful then, what, "elegance?" Who cares?

Re:What does $0=$2 in awk do? by piperswe on Sunday September 25, 2022 @10:57PM (#32978839)
Same here. I use `cat` as a tool to read data from the filesystem into a pipeline, regardless if that's the initial intention of the tool. I don't want the input filename being to the right of the first manipulation command in a pipeline that's supposed to read left to right!
Re:What does $0=$2 in awk do? by venil on Monday September 26, 2022 @03:16AM (#32980344)
Its actually part of the POSIX standard that redirections can be put anywhere in the command line, so one can do:

  <file.txt sed 's/some/filter' | other_cmd
on any standard compliantish shell :) (I use zsh, and I know it also works for bash and dash)
Re:What does $0=$2 in awk do? by jrm4 on Monday September 26, 2022 @09:28AM (#32982854)
Never knew this. Looking at it now. First impression, I can't tell if this is idiotic or genius :)