 <p>You can use this sed:</p> <pre><code>sed 's/\[[0-9]*\]=\(.*\)/+=(\1)/' file ARR+=(/var/dir1) ARR+=(/var/dir2) </code></pre> <p>Or this awk:</p> <pre><code>awk -F '\\[[0-9]+\\]=' '{printf "%s+=(%s)%s", $1, $2, ORS}' file ARR+=(/var/dir1) ARR+=(/var/dir2) </code></pre>