小编qin*_*eng的帖子

脚本中带有颜色选项的回显命令和命令的工作方式不同

如果我echo -e "\e[1;31mThis is red text\e[0m"在命令行中运行,它会打印出红色文本。

但是,如果我使用将其写入脚本文件中 test.sh

#! /bin/bash
echo -e "\e[1;31mThis is red text\e[0m"
Run Code Online (Sandbox Code Playgroud)

$ sh test.sh

它打印出来 -e \e[1;31mThis is red text\e[0m

为什么他们的行为不同?

command-line bash scripts

16
推荐指数
1
解决办法
7万
查看次数

标签 统计

bash ×1

command-line ×1

scripts ×1