开发者

Mirroring a string

开发者 https://www.devze.com 2023-02-25 07:21 出处:网络
How can I mirror a string? If found this: echo $(\"123\" | rev). 开发者_如何学CThis works fine. But when I put it in a variable, it doesn\'t display anything:

How can I mirror a string? If found this: echo $("123" | rev). 开发者_如何学CThis works fine. But when I put it in a variable, it doesn't display anything:

output=$("123" | rev)
echo $output

How can I get this done?


Fixed that for you:

output $(echo -n "123" | rev)
echo $output

If its in a subshell, make sure output is not local, and export it explicitely:

function bla()
{
    output=$(echo -n "123" | rev)
    export output
}

bla    
echo $output

Next time, you might want to mention more relevant context in your question :)

0

精彩评论

暂无评论...
验证码 换一张
取 消