This checks if either \
or /
are in the variable $string
.
if [[ "$string" == *\/* ]] || [[ "$string" == *\\* ]]
then
echo "yes"
fi
Test:
$ string="hello"
$ if [[ "$string" == *\/* ]] || [[ "$string" == *\\* ]]; then echo "yes"; fi
$
$ string="hel\lo"
$ if [[ "$string" == *\/* ]] || [[ "$string" == *\\* ]]; then echo "yes"; fi
yes
$ string="hel//lo"
$ if [[ "$string" == *\/* ]] || [[ "$string" == *\\* ]]; then echo "yes"; fi
yes