As far as i understand, considering the whole universe as a digital computer
executing a program is rather common among theoretical physicists nowadays:
https://en.wikipedia.org/wiki/Digital_physics
A syntactically-correct C program is word in the language C (any other
language can substitute C in the sentence), using the classical definition of
a formal language: https://en.wikipedia.org/wiki/Formal_language#Definition
When describing a specific programming language, "word" denotes a lo
Well, a (formal) language is defined as a set of words. Using that
definition all valid regular expressions (as given to grep) are a language,
all valid AWK programs are a language, etc.
AWK is a simple programming language. Contrary to grep (but like sed, what
is surprising), it is Turin
The script is also fast, which I was worried about given my files were very
large.
Notice that the shell is slow. It is a reason to substitute loops in shell
scripts (like "while read line; do ... ; done < file") with calls to commands
processing the whole input line by line. Essentially
Rereading the original post, I notice the task deals with "counting".
Assuming no repeated field in a same line, counting the total number of
repetitions (3, for the three lines you gave: 2, 12 and 102 are all repeated
once) shows the extremely useful END condition, satisfied once the whole
I never used awk much, if at all, so I have little experience with it (unlike
grep which I have used in a few occasions), which is why I didn't think of
using it.
AWK is a very simple programming language. Very simple to learn too,
especially if you know the basics of the languages that in
You can use that AWK program:
{ for (i = 1; i