title: How to measure time of execution of each "sub-process" of a shell script
body: <p>I'm running a program multiple times via script, but i need to get the time of execution of EACH time i run it. I'm trying to use the "time" function the same way as when i use it via terminal, but it doesn't really work. Here's my code with the "time" function inside the script:</p>
  
  <pre><code>#!/bin/sh
  time ./tree &lt; in_1.in &gt; out_1.out
  time ./tree &lt; in_2.in &gt; out_2.out
  time ./tree &lt; in_3.in &gt; out_3.out
  time ./tree &lt; in_4.in &gt; out_4.out
  time ./tree &lt; in_5.in &gt; out_5.out
  time ./tree &lt; in_6.in &gt; out_6.out
  time ./tree &lt; in_7.in &gt; out_7.out
  time ./tree &lt; in_8.in &gt; out_8.out
  time ./tree &lt; in_9.in &gt; out_9.out
  time ./tree &lt; in_10.in &gt; out_10.out
  </code></pre>
  
  <p>Note 1: Without the "time" before each line, the script runs perfectly. If possible, I'd like to put every recorded time into a new file, I tried using "echo", but haven't had any luck with it.</p>
  
  <p>Note 2: Is there a way to make my script run with every file inside a directory, without specifically putting every and each one inside my script?</p>