shell - Assign BASH variable from file with specific criteria -


a config file last line contains data want assign right of = sign variable can display , call later in script.

example: /path/to/magic.conf:

foo bar thisoption=foo.bar.address:location.555 

what best method in bash shell script read last line of file , assign right of equal sign? in case, foo.bar.address:location.555.

the last line has want target , there ever single = sign in file happens last line.

google , searching here yielded many close non-relative results using sed/awk couldn't come i'm looking for.

use sed:

variable=$(sed -n 's/^thisoption=//p' /path/to/magic.conf) echo "the option is: $variable") 

this works finding , removing thisoption= marker @ start of line, , printing result.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -