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