Live data from Hacker News

CLI text processing with GNU awk

learnbyexample.github.io

11–20 of 136 posts

Re: CLI text processing with GNU awk

#11
post #7

What is better? Starting with awk or sed?

While each with their scope and idiosyncrasies ... they're pretty similar, at least in the pattern matching part, and both of them have a pretty internal "core" of functionalities that is easy to grasp. so the honest answer IMHO is ... "both"

Re: CLI text processing with GNU awk

#13
Awk is fine and dandy but, like wity Sed, I think that it's almost always replaceable with Perl which is way nicer to use, and ubiquitous. Every OS (except Windows) I laid my hands on in the last 15 years has had Perl installed in either its default install or pulled in as a dependency almost immediately (a LOT of stuff depends on Perl in any Unix system).

This is, unless you are running on an embedded environment, but in that case you are stuck with something like busybox's Awk which is way more limited than gawk...

Re: CLI text processing with GNU awk

#14

Awk is fine and dandy but, like wity Sed, I think that it's almost always replaceable with Perl which is way nicer to use, and ubiquitous. Every OS (except Windows) I laid my hands on in the last 15 years has had Perl installed in either its default install or pulled in as a dependency almost immediately (a LOT of stuff depends on Perl in any Unix system). This is, unless you are running on an embedded environment, b…

> except Windows

On Windows, you use PowerShell.

Re: CLI text processing with GNU awk

#15

I have been using ChatGPT for generating these kind of small CLI like this. My prompts look like this: - use jq to count a nested array "a.b.c.d" - find and delete empty folders using `find` - find and replace text using sed/awk I found that using ChatGPT for these purposes boosted my productivity tremendously.

ChatGPT is a great time saver for those who already know how to use awk. But it should not be used by those who are unfamiliar.

Just an example, I saw someone come up with a great awk line to change some text in a nested directory. He then pasted into bash. Only once the server went down did anybody realize that he forgot to cd into the proper directory and he wiped out not only the server config but also all the user-uploaded data as well.

The server config was not version controlled and the user data had not been backed up in almost a week.

Re: CLI text processing with GNU awk

#16

Awk is fine and dandy but, like wity Sed, I think that it's almost always replaceable with Perl which is way nicer to use, and ubiquitous. Every OS (except Windows) I laid my hands on in the last 15 years has had Perl installed in either its default install or pulled in as a dependency almost immediately (a LOT of stuff depends on Perl in any Unix system). This is, unless you are running on an embedded environment, b…

[deleted]

Re: CLI text processing with GNU awk

#17

Awk is fine and dandy but, like wity Sed, I think that it's almost always replaceable with Perl which is way nicer to use, and ubiquitous. Every OS (except Windows) I laid my hands on in the last 15 years has had Perl installed in either its default install or pulled in as a dependency almost immediately (a LOT of stuff depends on Perl in any Unix system). This is, unless you are running on an embedded environment, b…

The obligatory perl replaced awk decades ago comment.

Soon to be followed by the ones saying nobody should be writing shell scripts at all anymore.

Re: CLI text processing with GNU awk

#19

Awk is fine and dandy but, like wity Sed, I think that it's almost always replaceable with Perl which is way nicer to use, and ubiquitous. Every OS (except Windows) I laid my hands on in the last 15 years has had Perl installed in either its default install or pulled in as a dependency almost immediately (a LOT of stuff depends on Perl in any Unix system). This is, unless you are running on an embedded environment, b…

> except Windows On Windows, you use PowerShell.

I prefer Cygwin.

Re: CLI text processing with GNU awk

#20
post #3

Hello! Author here. I am pleased to announce a new version of my "CLI text processing with GNU awk" ebook. Learn the `GNU awk` command step-by-step from beginner to advanced levels with hundreds of examples and exercises. This book will dive deep into field processing, show examples for filtering features, multiple file processing, how to construct solutions that depend on multiple records, how to compare records and…

I'm curious to know how many people you get paying for something like your "Magical one-liners", and also whether you've ever experimented with a "choose to pay after" model?

I ask because it's the kind of thing that I can imagine finding useful enough to pay $5 (or $15) for, but I can also imagine it being something that contains nothing I don't already have saved in my personal "one liners" file, so I'm not really interested in paying to find out.

Post reply on HN