Escape special characters inside folder/file name variable

array=(`find /path/ -mindepth 2 -maxdepth 2 -type d -print | sed -e ‘s;[^/]*/;;g’ |  sed ‘s/&/\\&/’`)

( sed ‘s/&/\\&/’  replaces & with \& in the folder/file name )

This entry was posted in Linux and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *