Joined November 2016
16 Photos and videos
Just released version 0.6.0.0 of h-gpgme, the #GPG wrapper for #Haskell, to hackage: hackage.haskell.org/package/… Release notes: github.com/rethab/h-gpgme/bl…
1
Ody Fusectore retweeted
23 May 2021
"Some of people's stupidest ideas are because they are insufficiently lazy" - James Gosling (@errcraft) podquotes.io/quote/23 #java #programming

1
Ody Fusectore retweeted
17 May 2021
"In terms of programming languages you get the most bang for the buck by learning AWK." - Brian Kernighan podquotes.io/quote/21

2
3
Ody Fusectore retweeted
"If we did not win a game, I did not look at my individual stats" - Anna Collins via @podquotesio
1
Ody Fusectore retweeted
9 Mar 2021
🤓 Let's talk about sorting in AWK 🤯 As you might know, arrays in AWK are backed by hashtables. This means traversing them (eg. via `for (i in arr)`) does not return values in any particular order. 💡How can we still ensure the output is sorted (in GNU AWK)? A thread.. ⬇️
1
1
3
Ody Fusectore retweeted
15 Jan 2021
🤓 How to join two files? 🧑‍🎓 Say we have a list withs ids and their names and one with ids and their ages. How to join them by id? > awk 'ARGIND==1{ages[$1]=$2} ARGIND==2{print $2, ages[$1]}' ages.txt names.txt anne 56 bob 23 chad 11 🤯❓ --> Thread ⬇️ #Linux #programming
2
3
6
Ody Fusectore retweeted
9 Jan 2021
📚 Weekend Read 📚 Many years ago, @WardCunningham has written a beautiful AWK script to calculate the expenses of their skip trip. c2.com/doc/expense/ 💡 This is AWK at its best.

1
5
12
Ody Fusectore retweeted
16 Dec 2020
👩‍🎨 How can we substitute strings in files? 👨‍🎨 💡 Use sub: > awk '{sub("ch", "xx")} 1' file.txt ➡️ Replaces the string "ch" with "xx" ➡️ But only the first occurrence ➡️ gsub replaces multiple 🤔 But how does this work? ⬇️ #Linux #AWK #programming
1
2
4
Ody Fusectore retweeted
10 Dec 2020
💡If you are like me, you cannot remember yesterday's FPAT. Put this into your ~/.bashrc, ~/.zshrc (etc..): alias csvawk='awk -v FPAT="([^,]*)|(\"[^\"] \")"' After reloading: > csvawk '{print $3}' file.txt "Berlin, Germany" You're welcome 😜 #Linux #AWK
1
1
3
12 Dec 2020
I have setup a monthly donation to @signalapp . Please consider supporting privacy in the internet: signal.org/donate/

2
Ody Fusectore retweeted
9 Dec 2020
👩‍🎨Parsing CSV with (GNU) AWK👨‍🎨 Simple CSVs can be handled with the field separator: `awk -F,` 🤔What about something like this? "anna",8,"Berlin, Germany" 💡FPAT to the rescue! > awk -v FPAT='([^,]*)|("[^"] ")' '{print $3}' file.txt "Berlin, Germany" #Linux #AWK #GNU
1
2
4
Ody Fusectore retweeted
4 Dec 2020
👩‍🎓 What if all data is on one line? 🤔 Eg. 'anna=10;bob=5;chad=7;danny=3' Can we still use #AWK? Of course! We just pretend that ';' is the newline separator 🤓 💡awk -v RS=';' -F= '{print $1}' ➡️ RS is the row separator. Usually this is \n #Linux #codingisfun
1
2
2
Ody Fusectore retweeted
2 Dec 2020
🤓 Day 2 of #AdventOfCode screams for #AWK 😱 But how can we do it in practice? 💡 the field separator accepts a regex, this allows us to split eg. "1-3 a: abcde" into fields 💡 the builtin function `gsub` returns the number of matches #AdventOfCodeSpoilers #Linux
1
2
2
Ody Fusectore retweeted
2 Dec 2020
😇 Enter trick 77: 'x=1{}x': works 📈 🤔Knowing this, we can rewrite the original solution to: 'BEGIN{FS="[- :]"}_=gsub($3,"",$5){}_>=$1&&_<=$2{x }END{print x}' This reduces the number of characters from 73 to 65. Can you come up with a shorter one? 🤓
1
Ody Fusectore retweeted
30 Nov 2020
🤔 Change a space-separated file to comma-separated: > awk -v OFS=, '{$1=$1}1' file.txt ➡️OFS modifies the output field separator from a space (default) to a comma. > awk -v OFS=, '{$1=$1; print $0}' file.txt ➡️same, but more explicit. #linux #cli #awk #programming
1
2
1
Ody Fusectore retweeted
27 Nov 2020
🤓 How to print unique lines by specific field in #AWK 🤓 > awk '!_[$3] ' file.txt ➡️ Prints all lines where field 3 was not seen before 🤔Magic? No! Read on ⬇️ #Linux #CLI #DevOps
1
2
3
Ody Fusectore retweeted
25 Nov 2020
🤓 You can write any number of patterns and blocks. 🤓 Every pattern-block combo is run on each line > awk '$1 == "anna" { print $2 } $2 == 5 { print $1 }' file.txt ➡️ Prints field 2 where field 1 is "anna" and also prints field 1 where field 2 is 4 #linux #awk #devops
1
2
Ody Fusectore retweeted
24 Nov 2020
🤓 AWK has a lot of defaults, which makes it hard to read unless you know them. > awk '{print $0}' file.txt ➡️ no pattern: print every line > awk '1' file.txt ➡️if there is only a pattern, the default is to print #AWK #Linux #shell #magic #cli
1
4
Ody Fusectore retweeted
23 Nov 2020
💡Booleans in Patterns: 0 is seen as false (block not run). Everything else is seen as true. awk '$2 % 2 { print $1 }' file.txt ➡️ prints lines where the second field is odd awk '$2 % 2 { print $1 }' file.txt ➡️ prints where the second field is not 0 #awk #unix #shell #cli
1
1
2
Ody Fusectore retweeted
22 Nov 2020
💡Patterns can also contain a regex. Just enclose it in slashes and compare it with a tilde (~): > awk '$1 ~ /^a/ { print $1} ' file.txt ➡️Print 1st column if it starts with an 'a'. awk '$1 ~ /[a-z]{4,}/ { print $0} ' file.txt ➡️ Print line if 1st column has at least 4 chars
1
1