代码之家  ›  专栏  ›  技术社区  ›  flash

从脚本输出中提取一个值并存储在变量linux中?

  •  -1
  • flash  · 技术社区  · 6 年前

    我有一个命令,如果我执行,它会给我以下输出:

    [abctt]$ /abc/prr/test.sh config -get center.id
    Connecting to the service endpoint at http://localhost:8003
    
    POY Properties:
    UU001
    

    现在我要提取“uuu001”值并存储在一个变量中,然后打印该变量值。所以我尝试了如下的方法,但它给了我错误:

    [abctt]$ id=`/abc/prr/test.sh config -get center.id | tail -2`;echo $id
    id=UU001: Command not found.
    id: Undefined variable.
    

    我在这儿干什么?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Benjamin W.    6 年前

    export id=`/abc/prr/test.sh config -get center.id | tail -2`;echo $id
    

    set id=`/abc/prr/test.sh config -get center.id | tail -2`;echo $id