modified to use shellescape instead of gsub