Search code examples
shellunixawk

nawk: no program given


there is a file the content like

 nawk  -v v1=$value1 -v v2=$value2 
                      'BEGIN {FS=OFS=",";

                      if ($7=v1 && test v2="ad"){
                         $19=4;
                         $20=1 ;   
                     }elif( $7=va1 && test v2="ac"){
                         $19=4;
                         $20=4;
                     }
                 } 1 ' $file > $file.result

when i run up script why there is error "n*awk: no program given*"


Solution

  • Put one '(single quote) at first line:

    nawk  -v v1=$value1 -v v2=$value2 '
        REST of COMMAND
    '