英文:
Concatenate "date" and "uptime" command in linux/adb
问题
I need to create a script which I need to concatenate the result of "date" with "uptime"
for example
Date:
date '+%a, %b %d %T %z %Y'
Mon Feb 13 15:04:05 GMT 2023
And when I run uptime into a terminal emulator appears the following:
15:04:34 up 2 days, 20:14, 0 users, load average: 1.95, 1.97, 1.81
Which I need to expect that those command is displayed into a single line:
Mon Feb 13 15:04:05 GMT 2023 15:04:34 up 2 days, 20:14, 0 users, load average: 1.95, 1.97, 1.81
I need perform this script to check the uptime with the date of an Android device using shell
Currently, I have this command but the uptime doesnt appears the "load average data"
adb -s 10.0.0.2:5555 shell "while true;do date '+%a, %b %d %T %Z %Y $(uptime)';sleep 1;done"
Mon, Feb 13 15:07:44 GMT 2023 12:07:44 up 40 days, 18:33, 0 users, load average: 0.00, 0.00, 0.00
So "Load average appears" 0.00
any helps pls
英文:
I need to create a script which I need to concatenate the result of "date" with "uptime"
for example
Date:
date '+%a, %b %d %T %z %Y'
Mon Feb 13 15:04:05 GMT 2023
And when I run uptime into a terminal emulator appears the following:
15:04:34 up 2 days, 20:14, 0 users, load average: 1.95, 1.97, 1.81
Which I need to expect that those command is displayed into a single line:
Mon Feb 13 15:04:05 GMT 2023 15:04:34 up 2 days, 20:14, 0 users, load average: 1.95, 1.97, 1.81
I need perform this script to check the uptime with the date of an Android device using shell
Currently, I have this command but the uptime doesnt appears the "load average data"
adb -s 10.0.0.2:5555 shell ""while true;do date '+%a, %b %d %T %Z %Y $(uptime)';sleep 1;done""
Mon, Feb 13 15:07:44 GMT 2023 12:07:44 up 40 days, 18:33, 0 users, load average: 0.00, 0.00, 0.00
So "Load average appears" 0.00
any helps pls
答案1
得分: 0
这是您需要的部分:
adb -s 10.0.0.2:5555 shell 'while true; do printf "%s %s\n" "$(date)" "$(uptime)"; sleep 1; done'
请注意引号和 printf
的用法以连接输出。
英文:
This is what you need
adb -s 10.0.0.2:5555 shell 'while true; do printf "%s %s\n" "$(date)" "$(uptime)"; sleep 1; done'
notice the use of quotes and printf
to join the output.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论