我fold
用来包装我的输入文件。我注意到一些彩色线条较短。我发现bash
将颜色代码视为字符,即使不可见。例子:
$ text="\e[0;31mhello\e[0m"; echo -e "$text - lenght ${#text}"
hello - lenght 18
$ text="hello"; echo -e "$text - lenght ${#text}"
hello - lenght 5
其他不可见字符也会发生这种情况:
$ text="a\bb\bc"; echo -e "$text - lenght ${#text}"
c - lenght 7
是否有可能改变这种行为?我希望coreutils
程序(bash
例如fold
)只能计算可见字符。