"/"
現在、文字列にaまたはaが含まれているかどうかをbashスクリプトでチェックしようとしています"\"
が、どういうわけか機能しません。
これが私がこれまでに得たものです:
if [[ "$1" == *\/* ]]; then
...
elif if [[ "$1" == *\\* ]]; then
...
fi
助けていただければ幸いです。ありがとう
\
これは、または/
が変数にあるかどうかをチェックします$string
。
if [[ "$string" == *\/* ]] || [[ "$string" == *\\* ]]
then
echo "yes"
fi
$ 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