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

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -