I need to get a value from a file where it is defined as variable1=value1
.
So if I do cat file | grep variable1
I get variable1=value1
.
I would like to do this inside a script so that variable1 is directly assigned value1.
I thought this might do it: cat file | grep variable1 | sh
but it doesn’t.
I know the same can be achieved by additional string processing and declaring variable1 explicitly inside the script, but my idea seems so elegant if I can get it to work. 🙂 And I am 99% sure it’s possible, I just can’t find the missing bit.