1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/env -S awk -f BEGIN { FS = "" } { for (i = 1; i <= NF; i++) { if ($i == "0") z[i]++ else o[i]++ } } END { for (i = 1; i <= NF; i++) { g = g (z[i] > o[i] ? "0" : "1") e = e (z[i] < o[i] ? "0" : "1") } (cmd = "echo 'ibase = 2;" g "*" e "' | bc") | getline out close(cmd) print out }