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 :)
精彩评论