Ubuntu20.04 系统,repo version v2.46 ,原来使用 repo status > xx.txt 一直都正常,从昨天开始执行词条命令后打开多了很多转义字符如下:
^[[1mproject RKDocs/android/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject RKDocs/common/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject RKTools/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject art/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject bionic/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject bootable/recovery/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject bootable/recovery/mtdutils/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject bootable/recovery/pcba_core/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject bootable/recovery/rkupdate/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject bootable/recovery/rkutility/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject build/blueprint/ ^[[m^[[1mbranch sky-8200-jiangsuyidong^[[m
^[[1mproject build/make/
其中^[[1m ,^[[m^[[1m 这些都是转义字符,网上查了和问了 ai 都没给搞定,求高人指点,谢谢
1
winzkh 115 天前
这是终端控制符,用来操纵终端显示的
|
4
yangg 115 天前
git config --global color.ui false
这个? |
5
hxy100 115 天前
过滤一下终端控制字符即可:
repo status |sed -e 's/\x1b\[[0-9;]*m//g' >xx.txt |
7
vituralfuture 115 天前 via Android
以 ls 为例,可以传入参数--color auto ,ls 会使用 ioctl 判断它的标准输出是终端还是文件,如果是终端就会打印颜色控制字符
|