Search code examples
awkparse-error

awk parse error on '<' operator


I'm trying to make an alias in .alias file for tcsh. Alias is something like this :

alias do "grep -iE '<pattern>' <file> | awk '{if($2 < 0)print}'"

When i try to run the alias it give me following error :

awk: cmd. line:1: {if( < 0.0) print}
awk: cmd. line:1:      ^ parse error

Any idea why this would happen ? Thanks.


Solution

  • Give this a try. You need to escape the single quotes and don't use any double quotes.

    alias do 'grep -iE '\''pattern'\'' filename | awk '\''{if ( $2 < 0 ) print}'\'''