hi :-)
I state not to know the bash-scripting .. && I do not know 'if it is written correctly && works correctly... but if this ""ESCAMOTAGE"" can be a help-to-solve:
http://postimg.org/image/wjer48wwn/full/