new*_*erl 2 bash terminal perl
print "\e[4m", $prompt, "\e[24m", "\e[1m";
Run Code Online (Sandbox Code Playgroud)
它似乎在bash中不起作用:
[root@dev-test ~]$ echo "\e[4mhello world\e[24m\e[1m"
\e[4mhello world\e[24m\e[1m
Run Code Online (Sandbox Code Playgroud)
小智 7
"\ e"表示用于VT100逃逸序列的 ESC 等.Perl理解字符串中的"\ e"转义序列并将其解释为ESC字符(它也可以写为"\ 33"或"\ x1b").
要使用ESC和echo,请提供-e允许处理这些转义的选项:
echo -e "\e[4mhello world\e[24m\e[1m"
Run Code Online (Sandbox Code Playgroud)
从两个字符"\ e"到单个ESC字符(值为0x1B)的转换由echo它自己完成(with -e) - shell不处理出现在引号中的转义.echo上面的链接还包括这种用法的示例.
快乐的编码.