亚行外壳输出将CRLF改为LF

我想通过Linux中的管道在bash adb shell循环中解析while命令的输出,但是adb shell总是输出DOS换行符而不是Unix / Linux换行符:

$ adb shell "echo Hello World" | file -b -
ASCII text,with CRLF line terminators

所以我总是需要音乐会,需要将DOS换行符转换为Unices',否则我将无法获得预期的结果:

$ adb shell pm list packages -3 | dos2unix | sort | cut -d: -f2 | \
while read appID; \
do \
echo "=> appID = $appID"; \
\curl -qs "https://play.google.com/store/apps/details?id=$appID"| pup --charset utf8 "title text{}" | awk -F' - ' '{print$1}'; \
done

我的问题如下:

如何设置adb shell而不是LF来输出CRLF

顺便说一句:dos2unix是我perl -pe 's/\r//g'的别名

EDIT0:命令adb exec-outadb版本1.0.31中不可用:

$ adb exec-out echo 2>&1 | head
Android Debug Bridge version 1.0.31

 -a                            - directs adb to listen on all interfaces for a connection
 -d                            - directs command to the only connected USB device
                                 returns an error if more than one USB device is present.
 -e                            - directs command to the only running emulator.
                                 returns an error if more than one emulator is running.
 -s <specific device>          - directs command to the device or emulator with the given
                                 serial number or qualifier. Overrides ANDROID_SERIAL
                                 environment variable.
....

编辑1:在此手机上找不到stty >

$ adb shell "stty raw;echo Hello World"
/system/bin/sh: stty: not found
Hello World
$ adb shell "stty raw;echo Hello World" | file -b -
ASCII text,with CRLF line terminators
$
lhb000 回答:亚行外壳输出将CRLF改为LF

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3088131.html

大家都在问