Awk has builtin functions which are operating on numbers and strings. That is exactly what a programming language does.
That makes me wonder if I can use awk to perform some number or string operations using awk, without specifying a file as input? Can awk work without input from file or stdin?
For example, I would like awk to evaluate 1+2
, and hardcode the "input" 1 and 2 in a awk program. Okay, I answer myself:
$ awk "BEGIN{print 1+2}"
3
But I am surprised that awk doesn't wait for input from stdin since I don't specify an input file. Why not?
Thanks.