Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • I can see you didn't test! The core logic works, but that's not the difficult bit. The difficult bit is quoting things properly, and you're not doing any of that. Try variables whose values contain newlines, ', *, etc. Commented Jun 14, 2014 at 23:13
  • echo "$LVALUE=\"$RVALUE\"" is supposed to keep the newlines as well and the result in the cfg_file should be like : MY_VAR1="Line1\nLine 2" Thus when eval MY_VAR1 it will contain the new lines as well. Of course you might have problems if your stored value contain itself " char. But that could be taken care as well. Commented Jun 15, 2014 at 5:34
  • 1
    Btw, why to down vote something which is answering correctly the question asked here? Above works very well for me and using everywhere in my scripts? Commented Jun 15, 2014 at 5:39