I\'m just looking for an easy way to divide a number (or provide other math functions). Let\'s say I have the following command:
find . -name \'*.mp4\' | wc -l
<
Using bc
:
$ bc -l <<< "scale=2;$(find . -name '*.mp4' | wc -l)/3"
2.33
In contrast, the bash shell only performs integer arithmetic.
Awk is also very powerful:
$ find . -name '*.mp4' | wc -l | awk '{print $1/3}'
2.33333
You don't even need wc
if using awk
:
$ find . -name '*.mp4' | awk 'END {print NR/3}'
2.33333