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
Post a Comment