bash - How can I subtract timestamp results from `date` in one line of shell? -
i can generate 2 timestamps so: date +"%s" -d "$(curl -s --head http://google.com | grep ^date: | sed 's/date: //g')" // result: 1417800327 date +"%s" // result: 1417800325 how can subtract them 1 line? echo "$((1417800327-1417800325))" // result: 2 but want closer to: echo "$(( (date +"%s" -d "$(curl -s --head http://google.com | grep ^date: | sed 's/date: //g')") - (date +"%s")))" try doing : lang=c echo $(( $(date +%s) - $(date -d "$(curl -s --head http://google.com 2>&1 | awk -f'date: ' '/^date:/{print $2}')" +%s) )) or splitted multi-lines readability : lang=c echo $(( $(date +%s) - $( date -d "$(curl -s --head http://google.com | awk -f'date: ' '/^date:/{print $2}' )" +%s) ))