T
T
taaadm2015-02-10 08:25:38
bash
taaadm, 2015-02-10 08:25:38

Why is the output of echo not being written to a variable (bash)?

Here is the code:

for word in $allUsers; do
    tmpStr=$(echo '{"{#EMAIL}":"'$word'"}' | python -lmjson.tool)
    echo $tmpStr
done

Writes an error:
Unknown option: -l
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

Didn't notice the typo, thanks DevMan. Before that, I tested the line separately, everything was good. And when copying, something is not pressed. Vi doesn't lend itself well to me. Now the line worked fine, but some problems with formatting appeared along the way. The conclusions differ
echo '{"{#EMAIL}":"'$word'"}' | python -mjson.tool
echo '{"{#EMAIL}":"'$word'"}' | python -mjson.tool

{
(indent here)"{#EMAIL}": "[email protected]"
}

and
tmpStr+=$(echo '{"{#EMAIL}":"'$word'"}' | python -mjson.tool)
echo $tmpStr

The conclusion is:
{ "{#EMAIL}": "[email protected]" }

Is that possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ShamblerR, 2015-02-25
@ShamblerR

I do
IP=$(ifconfig | grep inet | grep -v inet6 | grep -v 127.0.0.1 | cut -d: -f2 | awk '{printf $1"\n"}') | echo "RPAFproxy_ips 127.0.0.1 $IP"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question