Wednesday, 24 August 2011

how to use bash lists to time a group of commands

How do you run multiple commands in bash and calculate the total time taken to run all the commands? Use a list by surrounding the commands with curly braces:

time { sleep 2; uptime; true && date; }

The tricky bit is remembering to add that last semi-colon - without it, the command will fail to be parsed by bash. Also, the spaces either side of the curly braces are mandatory.

1 comment:

  1. Nice Post, Thanks for your very useful information... I will bookmark for next reference.

    ReplyDelete