Editing a playlist configuration file
Using sed to its fullest

sed is surprisingly powerful tool. For example:

finddir=$(sed -n -E /"${sfile}_finddir"'/s/[^"]*\"([^"]*).*/\1/p' "${sdir}/config.cfg")
[ -z ${finddir} ] &amp;&amp; finddir=${d_finddir}


achieves the desired effect without any egrep.


Explanation: The last line ([ -z ]) tests whether finddir has zero length (meaning that sed didn't find the line in interest) and if so (&amp;&amp;) assigns it a default value.

Editing the config file

I am not sure I understand the decision to edit the config file via the script. It is much more natural (at least within the context provided) to edit it manually.