How do I create an alias for awk command in
awk '{$1="";$2="";$3="";$4="";$5="";print}'
in tcshrc ?
I tried like this:
alias crd='awk '\''{$1=\"\";$2=\"\";$3=\"\";$4=\"\";$5=\"\";print}'\'''
but did not work
Your problem may just be that your backslash finger is too heavy. Double quotes inside the single quoted string do not need to be escaped unless they're part of a double-quoted string that is inside the single quotes.
But it may also be that you're confusing the bash alias
command with the tcsh alias
command. Bash notation looks like:
alias thing=command
whereas tcsh looks like:
alias thing command
Note the subtle difference. :-)
The following generates no errors for me:
% alias crd 'awk '\''{$1="";$2="";$3="";$4="";$5="";print}'\'''
The alias even seems to be functional:
% seq -s\ 1 8 | crd
6 7 8
You might also find this answer useful, if your goal is actually to remove columns rather than just nullify content.