命令替换bash

时间:2019-02-10 10:58:17

标签: bash shell sh

我有一个shell脚本

#! /bin/bash 

command='echo "hello world" '
timeout=10
cli_raw_output="$(timeout ${timeout} "${command}" 2>&1)" 
echo "$cli_raw_output"

在我执行时,它显示为

  

超时:无法运行命令`echo“ hello world”':没有这样的文件   或目录

我了解它会将“ echo“ hello world”“视为一个单词。 但是在这些情况下,我该如何执行呢?

我无法删除'command'变量周围的引号,因为我必须将'hello world'(这是一个要求)视为一个单词(尽管在此echo情况下不是必需的)。

0 个答案:

没有答案
相关问题