Reputation: 8941
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?
Upvotes: 4
Views: 2775
Reputation: 4771
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:
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. (Edited my answer a few times to make sure it fits exactly to your original command.)
Upvotes: 4