Digital Mark λ ☕️ 🌮 🚀 🌗 on Nostr: Doing some table generation in awk, and is there an easier way to do "all fields n to ...
Doing some table generation in awk, and is there an easier way to do "all fields n to NF" than this?
function combine(combn, combs) {
for (; combn<=NF; ++combn) {
combs=combs "\t" $(combn)
}
return combs
}
I could use printf on the fragments, but the annoyance is that loop, instead of
(string-join (cddr fields) "\t")
or whatever.
#awk #unix #codegolf
Published at
2025-03-09 09:14:22 UTCEvent JSON
{
"id": "229b2fb085b5a68f4b532336e7d591edd442dea53b9441114206aac4d4251a36",
"pubkey": "5b8b404c218a082fea628088dfe894011ffd044b0b7e90ac688ba91a68dde3a8",
"created_at": 1741511662,
"kind": 1,
"tags": [
[
"t",
"codegolf"
],
[
"t",
"awk"
],
[
"t",
"unix"
],
[
"proxy",
"https://appdot.net/@mdhughes/114131708300372786",
"web"
],
[
"proxy",
"https://appdot.net/users/mdhughes/statuses/114131708300372786",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://appdot.net/users/mdhughes/statuses/114131708300372786",
"pink.momostr"
],
[
"-"
]
],
"content": "Doing some table generation in awk, and is there an easier way to do \"all fields n to NF\" than this?\n\nfunction combine(combn, combs) {\n\tfor (; combn\u003c=NF; ++combn) {\n\t\tcombs=combs \"\\t\" $(combn)\n\t}\n\treturn combs\n}\n\nI could use printf on the fragments, but the annoyance is that loop, instead of\n(string-join (cddr fields) \"\\t\")\nor whatever.\n\n#awk #unix #codegolf",
"sig": "c9e21dfe3b117a525efd4d91c955b4aa83c064ec85bdf94592d9513435712c474630d545d10cc7d551e87d2da49e46120166c977a523bfd63bc2370d7e4884f5"
}