title: How to create a file using a variable as filename?
body: <p>I'm testing mobile Android devices and I would like to redirect the device log on a file whose name indicates both the date and time of my test, and the device model that is being tested.
  For the first issue, I have already resolved with</p>
  
  <pre><code>now=$(date +"%b_%d_%Y_%k_%M");adb logcat -c;adb logcat|tee $now
  </code></pre>
  
  <p>So:</p>
  
  <pre><code>$ echo $now
  Jan_03_2012_13_09
  </code></pre>
  
  <p>and the tee command creates a file with this filename.</p>
  
  <p>As for the device model I have written two bash lines that obtain it from adb shell, namely</p>
  
  <pre><code>device=$(adb shell cat /system/build.prop | grep "^ro.product.device=")
  deviceshortname=$(echo $device | sed 's/ro.product.device=//g')
  </code></pre>
  
  <p>(not optimal as I am not very good in bash programming... :) but I manage to get</p>
  
  <pre><code>$ echo $deviceshortname
  LT15i
  </code></pre>
  
  <p>My problem is how to combine <code>$now</code> and <code>$deviceshortname</code> to obtain a filename such as:
  <code>LT15i_Jan_03_2012_13_19</code></p>
  
  <p>I tried to set another variable:</p>
  
  <pre><code>filename=($(echo $deviceshortname"_"$now))
  </code></pre>
  
  <p>and got:</p>
  
  <pre><code>$ echo $filename
  LT15i_Jan_03_2012_13_19
  </code></pre>
  
  <p>but if I try redirecting the log:
      $ adb logcat | tee $filename</p>
  
  <p>I obtain such file:</p>
  
  <pre><code>-rw-r--r--+ 1 ele None     293 Jan  3 13:21 ?[01;31m?[K?[m?[KLT15i_Jan_03_2012_13_19
  </code></pre>
  
  <p>I don't know why these strange characters and what I'm doing wrong.</p>