I have a file with the following:
37 * 60 + 55.52
34 * 60 + 51.75
36 * 60 + 2.88
36 * 60 + 14.94
36 * 60 + 18.82
36 * 60 + 8.37
37 * 60 + 48.71
36 * 60 + 34.17
37 * 60 + 42.52
37 * 60 + 51.55
35 * 60 + 34.76
34 * 60 + 18.90
33 * 60 + 49.63
34 * 60 + 37.73
36 * 60 + 4.49
I need to write a shell command or Bash script that, for each line in this file, evaluates the equation and prints the result. For example, for line one I expect to see 2275.52
printed. Each result should print once per line.
I've tried cat math.txt | xargs -n1 expr
, but this doesn't work. It also seems like awk
might be able to do this, but I'm unfamiliar with that command's syntax, so I don't know what it would be.
bc
command. I figured just basic shell utilities would get it done but I guess not? – void.pointer Nov 21 '19 at 18:48awk
? – schrodingerscatcuriosity Nov 21 '19 at 19:21bc
is a "basic shell utility" – jesse_b Nov 21 '19 at 19:24awk
. @jesse_b I assumed that to getbc
I'd have to use a package manager, which I don't have in this version of mingw, so to me "basic" means what is included already. Sorry, it ended up being a rather ambiguous and useless statement. – void.pointer Nov 22 '19 at 00:19bc
because it claims to be POSIX compliant and POSIX requires the environment providebc
– slebetman Nov 22 '19 at 04:47