Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7004531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:12:39+00:00 2026-05-27T21:12:39+00:00

I’m testing mobile Android devices and I would like to redirect the device log

  • 0

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

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 this filename.

As for the device model I have written two bash lines that obtain it from 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 as I am not very good in bash programming… 🙂 but I manage to get

$ echo $deviceshortname
LT15i

My problem is how to combine $now and $deviceshortname to obtain a filename such as:
LT15i_Jan_03_2012_13_19

I tried to set another variable:

filename=($(echo $deviceshortname"_"$now))

and got:

$ echo $filename
LT15i_Jan_03_2012_13_19

but if I try redirecting the log:
$ adb logcat | tee $filename

I obtain such file:

-rw-r--r--+ 1 ele None     293 Jan  3 13:21 ?[01;31m?[K?[m?[KLT15i_Jan_03_2012_13_19

I don’t know why these strange characters and what I’m doing wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:12:39+00:00Added an answer on May 27, 2026 at 9:12 pm

    Something is adding color to your output. It might be grep(1), it might adb, it might be baked into the /system/build.prop resource that you’re reading.

    If you’re lucky, it is being added by grep(1) — because that is supremely easy to disable with --color=no:

    device=$(adb shell cat /system/build.prop | grep --color=no "^ro.product.device=")
    deviceshortname=$(echo $device | sed 's/ro.product.device=//g')
    

    If the colors are being added by adb, then perhaps it has a command line option that asks it to avoid colorizing the output.

    If the colors are hard-coded into the /sys/build.prop resource in some way, then you’ll need some little tool that filters out the color codes. I don’t have one handy (and it’s bedtime) but you can probably build one starting with tr(1) to delete \033 ASCII ESC characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.