在`alias`中加上引号是`CSH`
我想要一个能够执行以下命令的别名:
zgrep 'failed at' $PWD/RESULTS/log_dir/* | cut -d"'" -f2,4 | tr "'" "\t"
我尝试了不同的方法将其放入别名,但似乎都不起作用。 例如,我的一些尝试:
alias get_failed "zgrep 'failed at' $PWD/RESULTS/log_dir/* | cut \"\'\" -f2,4 | tr \"\'\" \"\\t\""
alias get_failed "zgrep 'failed at' $PWD/RESULTS/log_dir/* | cut \"\'\" -f2,4 | tr \"\'\" \"\\t\"
以及其他尝试,我怎样才能创建我的别名?
I want to have an alias that will execute the fallowing command:
zgrep 'failed at' $PWD/RESULTS/log_dir/* | cut -d"'" -f2,4 | tr "'" "\t"
I've tried different ways to put it to an alias but none of them seem to work.
for example, some of my tries:
alias get_failed "zgrep 'failed at' $PWD/RESULTS/log_dir/* | cut \"\'\" -f2,4 | tr \"\'\" \"\\t\""
alias get_failed "zgrep 'failed at' $PWD/RESULTS/log_dir/* | cut \"\'\" -f2,4 | tr \"\'\" \"\\t\"
and others, how can I make my alias?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题是由 csh 功能引起的:如果您已经位于“”引用的字符串中(与 ' 相同),则无法转义 "。由于兼容性问题,这仍然是默认值。您可以使用更理智的 shell 或使用
backslash_quote
配置:另外,请注意,您对 cut 的调用会删除任何单引号 ('),因此您的 tr 调用不会做太多事情。 (多次编辑我的答案,以确保它完全符合您原来的命令。)
The issue is caused by a csh feature: you can't escape " if you already are in a "-quoted string (it's the same for '). This is still the default due to compatibility issues. You could either use a saner shell or use the
backslash_quote
configuration:Also, note that your call to cut removes any single quote (') so your tr call won't do much. (Edited my answer a few times to make sure it fits exactly to your original command.)