Using sed to its fullest
sedis surprisingly powerful tool. For example:finddir=$(sed -n -E /"${sfile}_finddir"'/s/[^"]*\"([^"]*).*/\1/p' "${sdir}/config.cfg") [ -z ${finddir} ] && finddir=${d_finddir}achieves the desired effect without any
egrep.- Requsted explanationExplanation: The last line (
[ -z ]) tests whetherfinddirhas zero length (meaning thatseddidn't find the line in interest) and if so (&&) assigns it a default value.
- Requsted explanationExplanation: The last line (
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.