5 ms·
That's nifty. $ echo "$SECONDS / 60 / 60" | bc 362.38500000000000000000
by monsieurbanana 9y ago
That's nifty.
$ echo "$SECONDS / 60 / 60" | bc
362.38500000000000000000
- 1024core 9y ago"bc", without the "-l" option, will give you integers only. So the response of the command above will be "362", and not "362.38500000000000000000"
- mikegerwitz 9y agoecho "$(( SECONDS / 60 / 60 ))"
- vram22 9y agoecho "scale=2; $SECONDS / 60 / 60" | bc # will give 2 digits after the decimal point, instead of bc -l which gives more digits of precision after the decimal point, than we may usually want for this particular calculation.
- lozf 9y agoRecently I needed results that included nothing after the decimal point, so resorted to awk to do the math: awk "BEGIN { print int($SECONDS /60 /60)}"
- vram22 9y agoInteresting. I suppose you had to type Ctrl-D or Ctrl-Z to signal no input to awk, since it expects some in the above command? Never tried running awk without either a filename as input or stdin coming from a file or a pipe. Will check it and see what happens. Modifying my example from above: echo "scale=0; $SECONDS / 60 / 60" | bc might also work, need to check.
- otherflavors 9y agoprintf "%s 60 60 *2k/p" "$SECONDS" | dc