Converting Minutes and Seconds to Seconds in a BASH Script

Recently I had a need to calculateĀ  seconds out of minutes and seconds. The BASH script below will take two integer arguments separated by a space and return a value in seconds.

min-sec-to-seconds.sh

#!/bin/bash

seconds=$[60*$1+$2]

echo $seconds

Leave a Reply

Your email address will not be published. Required fields are marked *