Is anyone using awk?

Studying and awk came up.

Spent about an hour and I see some useful commands that extend past what “cut” can do. But really when dealing with printf() format statements is anyone using awk scripts for this?

Or is everyone just using their familiar scripting language. I’d reach for Python for the problems being presented as useful for awk.

eestileib,

Perl kinda killed awk and sed.

Then python kinda killed perl.

AnUnusualRelic,
@AnUnusualRelic@lemmy.world avatar

I used awk until perl, then there was no going back.

filister,

Just use awk and when needed ask ChatGPT for the syntax of the command

ikidd,
@ikidd@lemmy.world avatar

Just had to use it today to turn a key file into a single string with line breaks:

awk ‘NF {sub(/r/, “”); printf “%s\n”,$0;}’ id_rsa

tanakian,

awk often can be found in my scripts.

willybe,

I used awk to migrate users from one system to another. I created template scripts for setting up the user in the new system, I dumped the data from the old system, then used awk to process the dump and create scripts for each user in the new system. That was a fun project.

ninekeysdown,
@ninekeysdown@lemmy.world avatar

Everyday. I’ve got a lot of stuff that uses it. Granted most of it was mostly created a decade ago but with minimal maintenance it works great. The most helpful script is parsing megacli outputs so I can get a heads up on drive failures and rebuilds among other things.

otl,
@otl@lemmy.sdf.org avatar

I use it for my very basic static site generator: www.olowe.co/2021/01/site-build.html

Legisign,

cut is actually next to useless, because it cannot understand that multiple spaces can still be a single separator in most text files in /etc. You have to use AWK.

OpenStars,
@OpenStars@discuss.online avatar

awk is awesome! I love it, and I do not regret learning how to use it.

That said, my workflow invariably always shifts from starting with awk to do something simply with a tiny one-liner, to then doing that with perl or python, and sometimes even creating a file to make the by-now multi-line scripts more easily readable.

I do not recommend starting with awk, if you do not know other languages already such as Python.

In short, let your intuition guide you.

visika,

I used awk in a physics computer simulations course I had at the university. That’s a nice tool to know how to use

MonkderZweite,

My only usecase was finding and cutting at the same time. Until i noticed that grep | cut -d… 5x faster is.

allywilson,

I don’t tend to use awk in scripts as I do tend to do them in Python, but I do use awk on almost daily basis in one-liners.

Probably the most common thing for me is so I can read a config file without annoying comments and big line spaces.

grep -v “^#” krb5.conf | awk NF

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #