Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试做一个简单的if陈述,但其中一个字符串包含方括号。
if
我试过了\ ' " +,一切都在我脑海中浮现。
\ ' " +
我基本上是这样的:
if [ $MESSAGE = "username [$USERNAME] is already taken" ]
在这种情况下,我想抛出一条错误消息。
引用 $MESSAGE 为好。如果该变量确实包含 [,它将影响解析。
if [ "$MESSAGE" = "username [$USERNAME] is already taken" ]