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 use…
CLI text processing with GNU awk
21–30 of 136 posts
Re: CLI text processing with GNU awk
#22Awk 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
#23Re: CLI text processing with GNU awk
#24https://www.gnu.org/software/gawk/manual/html_node/Extension...
Re: CLI text processing with GNU awk
#25Awk 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…
Re: CLI text processing with GNU awk
#26Hello! 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…
You can see the number of paid sales for the bundles under the "I want this!" button. When the price is 0, it shows the total of both paid/free users.
I started selling ebooks about 5 years back. Where I live, my monthly living cost is just $150. While the first two years of sales were just about enough to cover my costs, the last three years have been much better - I can continue being self-employed :)
Re: CLI text processing with GNU awk
#27Awk 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…
And I wrote a book for Perl one-liners as well (https://learnbyexample.github.io/learn_perl_oneliners/), which I'm currently revising (like I did for the grep/sed/awk ebooks).
Re: CLI text processing with GNU awk
#28I suspect that anyone reading this thread is likely to be equally interested in "Ask HN: Share a shell script you like" from a fortnight ago (though at 78 comments, it didn't get as much traction / comments as I hoped it would when I saw it) https://news.ycombinator.com/item?id=37112991
And here's one from last year: https://news.ycombinator.com/item?id=32467957 (374 points | 294 comments)
Re: CLI text processing with GNU awk
#29I suspect that anyone reading this thread is likely to be equally interested in "Ask HN: Share a shell script you like" from a fortnight ago (though at 78 comments, it didn't get as much traction / comments as I hoped it would when I saw it) https://news.ycombinator.com/item?id=37112991
There was a similar discussion 5 months back: https://news.ycombinator.com/item?id=35122780 (332 points | 328 comments) And here's one from last year: https://news.ycombinator.com/item?id=32467957 (374 points | 294 comments)
Re: CLI text processing with GNU awk
#30What is better? Starting with awk or sed?
However, sed has grown out of the command language used by the tty editors, and is more difficult to program (although it is Turing-complete).
The awk language implements much of the syntax of C, and it is not difficult to write a very slow and inefficient script. This inefficiency is harder to reach in sed, because it takes more effort to abuse it.
O'Reilly's book on sed and awk is available free online, both to browse and to download as a ZIP.