为什么我不能回应人物#!用bash中的字符串?
发布时间:2020-12-15 18:59:31 所属栏目:安全 来源:网络整理
导读:参见英文答案 echo “#!” fails — “event not found”5个 我有一个小的bash脚本应该移动到我的主目录,创建一个文件,回收一些垃圾,并使其可执行.这就是它的样子: cd ; touch tor.sh; echo "#!/bin/bashn/usr/local/bin/tor" tor.sh; chmod +x tor.sh 但
参见英文答案 >
echo “#!” fails — “event not found”5个
我有一个小的bash脚本应该移动到我的主目录,创建一个文件,回收一些垃圾,并使其可执行.这就是它的样子: cd ; touch tor.sh; echo "#!/bin/bashn/usr/local/bin/tor" >> tor.sh; chmod +x tor.sh 但这仍然在回声中打破,抱怨“未找到事件”?出于某种原因,我决定尝试这个并且它有效: cd ; touch tor.sh; echo -e "x23x21/bin/bashn/usr/local/bin/tor" >> tor.sh; chmod +x tor.sh 为什么我必须用十六进制和-e替换这两个字符(shebang?)?有一个更好的方法吗?
这不是一个错误,它与shebang无关,只是感叹号.
Enclosing characters in double quotes preserves the literal value of all characters within the quotes,with the exception of $,`,,and,when history expansion is enabled,!. 所以要么逃避它,使用单引号,要么关闭历史扩展. 例如 > echo "How dare you put an '!' in this string?" bash: !: event not found > set +o histexpand > echo "How dare you put an '!' in this string?" How dare you put an '!' in this string? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- macos – 如何从shell中检测Mac OS X中的当前区域
- scala – 如何为隐式方法实现中间类型?
- shell – 如何在FreeBSD中获得以毫秒为单位的时间
- bootstrap javascript插件中类成员命名之最前面有
- axis2 webservice 调用的三种方式 .
- 通过AngularJS中的服务将数据加载到控制器中的方
- Couldn't register with the bootstrap serv
- WebSphere Message Broker(11)--webservice服务封
- angularjs – 如何使用webpack编译角度模板?
- scala – 使用重复参数的成本
热点阅读