Live data from Hacker News

The Awk Programming Language

awk.dev

121–130 of 159 posts

Re: The Awk Programming Language

#121
post #98

I know lots of people like awk, but I pretend it doesn't exist. Why? Here's my comment on this from 6 years ago[0], >I used awk until I learned Python (long ago). For me, awk was yet another example of the "worse is better" approach to things so common in unix. For example, if you make a syntax error, you might get a message like "glob: exec error," rather than an informative message. "Worse is better" is probably a…

Specifically, Awk is a good solution to a problem that should never have existed in the first place. Why am I having to write these bespoke parsers for the random mess of output formats that you get from the UNIX command line?

Well, the fact is that I have to write such parsers. That's very sad, but has no chance of being fixed. So it's good to know Awk.

I think Erik Naggum had this exact criticism of Perl.

Re: The Awk Programming Language

#122

Earlier quoted context omitted.

Its a crying shame we never settled on a control character separated text format. There's a ascii control characters for record and field (unit) separators. A bit of user space support for that would have been great.

As I recall, you can tell Awk to use the control characters as record and field separators. Not helpful if you're getting your data from others, but if you're working by yourself, you have the option. I've come to use control characters as a default because it makes life so much easier.

What do you recommend for viewing and editing such files?

Re: The Awk Programming Language

#123

Earlier quoted context omitted.

Perl? Wow. Is that better than bash, python or even nodejs? Why write in Perl over these? Serious question, was propaghandized to hate Perl.

Have you ever tried to dig a hole? What tool did you use? - Want to cut through and move loam, compost, sandy, and compacted soil? You're gonna want a rounded shovel. - Want to break up rocky, clay soil? A pick mattock will penetrate deep, breaking up soil, shattering smaller rocks, and is used as a lever to uproot. A tiller is a faster method but disturbs the soil more. - Want to dig a narrow, deep hole? An augur wi…

Perl can do sh/awk/sed and a bunch more at once.

Re: The Awk Programming Language

#124

Earlier quoted context omitted.

Perl can also be hilariously unreadable: https://www.foo.be/docs/tpj/issues/vol4_3/tpj0403-0017.html

>> Perl can also be hilariously unreadable: https://www.foo.be/docs/tpj/issues/vol4_3/tpj0403-0017.html Most programming languages can be obfuscated. That does not mean people write code in those programming languages like that: C: https://www.ioccc.org/ Javascript: view-source: https://www.google.com/ The truth is that insulting Perl is considered stylish by some, so many people do despite knowing little to nothing…

[flagged]

Re: The Awk Programming Language

#125
post #122

Earlier quoted context omitted.

As I recall, you can tell Awk to use the control characters as record and field separators. Not helpful if you're getting your data from others, but if you're working by yourself, you have the option. I've come to use control characters as a default because it makes life so much easier.

What do you recommend for viewing and editing such files?

Visidata works with arbitrary separators. I just tried with a CSV separated with ␟ (ASCII unit separator) and it worked just fine.

Re: The Awk Programming Language

#126
post #25

I was privileged to be one of the technical reviewers for this book. There's a fair bit of the original content (which is still great), but Kernighan's done a great job with some good restructuring and some significant updates, too. The early chapters are very hands-on, with something of a focus on "exploratory data processing", particularly with CSV files. Big data with AWK, you could say. Gawk and awk will soon hav…

Its a crying shame we never settled on a control character separated text format. There's a ascii control characters for record and field (unit) separators. A bit of user space support for that would have been great.

Most important comment I have ever read on HN ever !

Re: The Awk Programming Language

#128
post #124

Earlier quoted context omitted.

>> Perl can also be hilariously unreadable: https://www.foo.be/docs/tpj/issues/vol4_3/tpj0403-0017.html Most programming languages can be obfuscated. That does not mean people write code in those programming languages like that: C: https://www.ioccc.org/ Javascript: view-source: https://www.google.com/ The truth is that insulting Perl is considered stylish by some, so many people do despite knowing little to nothing…

[flagged]

It's like when we, Gen-X ers, were repeating bad stuff about COBOL without having seen a single line of it.

Then I saw a real COBOL program and... well... it was even worse than what I had imagined :-)

Re: The Awk Programming Language

#129
Amazing, takes me back.

~

One of my first big projects at my first job fresh out of college was using sed & awk to semi-automate the transformation of semi-unstructured data into a database.

IIRC I couldn't completely automate because it contained author names, from global naming conventions. (parsing names correctly is deceptively complex) They had somewhat arbitrary #'s of initials ranging from 0-3.

Again, IIRC, I could easily accommodate 0 or 1 initial (followed by \.) but trying for more would make the regex I was using too greedy and pull in part of the article abstract. These were scientific books and journals.

So I scripted a sed & awk program to detect the possibility of > 1 initials and when that occured, I'd pipe the record into nano for a quick review where I manually inserted the correct \. characters for the initials.

It was decades of back-catalogue publications for digitization so I sat there for days, listening to music on an original 1st gen iPod, waiting for my duct-taped kludge of a program to pipe one of thousands of records into a nano session every few minutes. This was on an Apple G4 workstation running OS X, where I earned my real bash scripting chops. It was an awful hack by today's standards, but at the time, accomplishing what was expected to be a 1-year long project in ~1 month, it was seen as nearly miraculous.

Post reply on HN