【问题标题】:bash : read a line from a file and interpret this line [duplicate]bash:从文件中读取一行并解释这一行[重复]
【发布时间】:2014-12-17 22:29:11
【问题描述】:

我有一个包含这一行的文件,例如:

${blue}*Passed*${NC}: check the command line ...

我可以在 bash 中读到这一行:

red='\e[41m'
blue='\e[1;34m'
purple='\e[1;31m'
NC='\e[0m' # No Color

 while read line
 do
      echo -e $line
 done < test_contest

但是输出是这样的:

${blue}通过${NC}:检查命令行...

没有颜色,bash 可以将此行解释为输出颜色吗?

【问题讨论】:

    标签: bash


    【解决方案1】:

    只是改变:

    echo -e $line
    

    与:

    eval echo -e \"$line\"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-07
      • 2023-04-03
      • 2014-01-02
      • 2016-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-25
      相关资源
      最近更新 更多