Evgeniy A Evgeniy A - 1 year ago 75
Linux Question

Multiply by the number of command output

Good afternoon there was a need to translate seconds to milliseconds. Script:

a=$(ffprobe -i c848a39afc54e04cc64ddd955686654b9b1c6f31 -show_entries format=duration -v quiet -of csv="p=0");
echo $result


./sectomilisec: line 4: 23.760000*1000: syntax error: invalid arithmetic operator (error token is ".760000*1000")

Answer Source

bash doesn't support float operation. You can use bc for this:

result=$(echo "$a*$b" | bc)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download