问题
在服务器上执行指令报错。
-bash: !'": event not found
解决
这是因为感叹号在linux上视作命令,属于特殊字符,如果想正常使用,必须进行转义。
可使用单引号,保证字符串按照原始输出。
举例
报错指令
curl -X POST -d "data=123!" http://localhost/test
正确指令
curl -X POST -d 'data=123!' http://localhost/test
本文介绍了在Linux环境下如何处理特殊字符引发的错误,并通过具体示例演示了如何使用单引号来转义感叹号,确保命令能够正确执行。
在服务器上执行指令报错。
-bash: !'": event not found
这是因为感叹号在linux上视作命令,属于特殊字符,如果想正常使用,必须进行转义。
可使用单引号,保证字符串按照原始输出。
curl -X POST -d "data=123!" http://localhost/test
curl -X POST -d 'data=123!' http://localhost/test