START=$(date +%s) # do something # start your script work here ls -R /etc > /tmp/x rm -f /tmp/x # your logic ends here END=$(date +%s) DIFF=$(( $END - $START )) echo "It took $DIFF seconds"
START=$(date +%s) # do something # start your script work here ls -R /etc > /tmp/x rm -f /tmp/x # your logic ends here END=$(date +%s) DIFF=$(( $END - $START )) echo "It took $DIFF seconds"
Вместо всего — одна строчка:
echo "It took $SECONDS seconds"
time script.sh
Спасибо, пригодилось!