bash - 引用/保护通过管道传输到 bash 的特殊字符?
问题描述
我有
$ cat afile
file(1).txt ./adir
$ cat question.sh
#!/bin/bash
sed -e 's/^/mv /' afile | bash
$ ./question.sh
bash: line 1: syntax error near unexpected token `('
bash: line 1: `mv file(1).txt ./adir'
对于文件名中bash
的特殊字符,我如何保护管道输入的行?可能还有其他我事先不知道的特殊字符,因此我正在寻找一种通用的方法来处理所有字符。()
file(1).txt
解决方案
推荐阅读
- python - 如何在以字母python开头的列表中追加项目
- javascript - 有没有办法在 ejs 中使用保留的 javascript 关键字作为对象键?
- c# - 没有任何 toLower 方法,它怎么会发生一个简单的字符串条件忽略区分大小写
- java - 打开新的Jframe并关闭以前的好方法吗?
- java - 如何在 wso2 EI 6.3.0 中使用“text/plain”作为内容类型来格式化电子邮件正文?
- javascript - 按星期和日期对 DataTable 进行排序
- node.js - 如何在节点js中显示来自api(计算机视觉-azure中的缩略图服务)响应的网页中的图像
- symfony - 如何从上面的当天停用日期
- python - 如何使用两个列表制作字典,但我想要两个作为值并且键将是名称和 sys-id?
- webview - 有什么方法可以使用 Url_launcher 插件在 Iphone 浏览器上隐藏 url