I wish to find out how long an operation takes in a Linux shell script. How can I do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using the time command, as others have suggested, is a good idea.
Another option is to use the magic built-in variable $SECONDS, which contains the number of seconds since the script started executing. You can say:
I think this is bash-specific, but since you’re on Linux, I assume you’re using bash.