简体   繁体   English

在“别名”中加上引号是“CSH”

[英]putting quotation marks in `alias` is `CSH`

I want to have an alias that will execute the fallowing command: 我想要一个将执行fallowing命令的别名:

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? 和其他人,我怎么能做我的别名?

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 '). 问题是由csh功能引起的:如果你已经在“引用的字符串中,你就无法逃脱”(它与'相同)。 This is still the default due to compatibility issues. 由于兼容性问题,这仍然是默认设置。 You could either use a saner shell or use the backslash_quote configuration: 您可以使用saner shell或使用backslash_quote配置:

set backslash_quote
alias get_failed "zgrep 'failed at' $PWD/RESULTS/log_dir/* | cut -d\"'\" -f 2,4 | tr \"'\" \"\\t\""

Also, note that your call to cut removes any single quote (') so your tr call won't do much. 另外,请注意您的cut to call会删除任何单引号('),因此您的tr调用不会有太大作用。 (Edited my answer a few times to make sure it fits exactly to your original command.) (编辑我的答案几次,以确保它完全符合您的原始命令。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM