shell - Store result of an operations in a variable in bash -


i have command in bash returns locale of ip address stored in variable $line. command looks this:

geoiplookup -f geoip.dat "$line" >> resultfile 

which return result such "new york, ny".

now want concatenate ip address result looks this:

"215.216.217.218, new york, ny"

so like:

$line +", "+ (geoiplookup -f geoip.dat "$line") >>resultfile 

can give me correct syntax this?

how about

echo "$line, $(geoiplookup -f geoip.dat "$line")" >> resultfile 

this relies on backtick operator of bash $(...) executes command , captures output. in above line, bash execute geoiplookup -f geoip.dat "$line" , put output in place of $(...) part.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -