tags:

views:

22

answers:

1

Here are the contents of a file:

one two three
four five six

And here is my alias

alias testawk "awk '{print $2}' file"

This is what I get:

> testawk
one two three
four five six

But when I give this command, then I get what I want:

> awk '{print $2}' file
two
five

How do I escape the field specifier in the alias? NOTE: I'm using csh

+2  A: 

Wrap the alias w/ ' and use '\'' for the embedded '.

alias testawk 'awk '\''{print $2}'\'' file'
lrm
I didn't see that you were using csh first. This corrected answer should work for you.
lrm
@lrm Thanks. I hate all those little quirks of csh. Its too bad I'm forced to use it here at my work.
B Johnson