32

Is there a way to time a series of commands in linux?

Perhaps something like this:

/usr/bin/time { ls; pwd; ls }
juniper-
  • 465

2 Answers2

46

Using time use () to create a subshell for the commands you wish to time. The syntax would be:

time ( ls; pwd; ls )

If using /usr/bin/time then add the commands to a shell script (for example my.sh) and time the shell script-:

/usr/bin/time my.sh
suspectus
  • 5,008
14

You could try to wrap it in a shell command:

/usr/bin/time /bin/sh -c 'ls;pwd;ls'
faffaffaff
  • 815
  • 8
  • 7