I'm trying to assign a variable with a value I get from grep, here's my code
a="i
am
a
string
"
b="$a"|grep am
echo "$b"
I expect the result is am
, but the result b
is empty. But when I code echo "$a"|grep am
directly, I get the right result. why and how can I assign the result to b?