【发布时间】:2023-03-13 17:15:01
【问题描述】:
我已阅读其他帖子,但不知何故,解决方案不起作用。
perl -p0777e "s/('|"")/^&/g" "E:\output.csv" > "E:\output2.csv"
我试过了
perl -p0777e "s/('|^")/^&/g" "E:\output.csv" > "E:\output2.csv"
perl -p0777e "s/('|\")/^&/g" "E:\output.csv" > "E:\output2.csv"
我尝试将所有其他可能的有趣字符与转义字符一起使用,但没有成功。我知道问题出在 " 字符上,因为我在同一个 FOR 循环中运行这个 perl 命令的变体。
这是最上面语法的错误消息:
Bareword found where operator expected at -e line 1, near "s/('|")/^&/g E"
syntax error at -e line 1, near "s/('|")/^&/g E"
Execution of -e aborted due to compilation errors.
我不知道包含 E 是因为接近还是因为“混淆”。我可以尝试一下。
谁能帮我弄清楚如何安全地传递这个 S&R 命令?提前谢谢你。
编辑:我什至无法正确评论...
最近一次尝试是
perl -p0777e "s/^(^'^|^"^)/^&/g" "E^:\output.csv" > "E:\output2.csv"
没有成功。错误信息是
Bareword found where operator expected at -e line 1, near "s/^(^'^|^)/&/g E"
syntax error at -e line 1, near "s/^(^'^|^)/&/g E" Execution of -e aborted
due to compilation errors.
【问题讨论】:
标签: perl batch-file escaping syntax-error bareword