compare minus symbol "-" with a column
Need to compare minus symbol "-" with a column that contains minus on few rows.
the sample script awk I have written is
if ( '$COLUMN2' ~ "\-" ) {}
COLUMN2 is a shell variable. I just need the if condition checking the shell variable within the awk script. Below is the entire awk part of the script in case if my question is not clear.
newline=$(echo | awk '{
case1=0;
case2=0;
case3=0;
case4=0;
if ( '$COLUMN3' == 0 ) {
if ( case1 == 0 ){
if ( '$COLUMN5' > 0 ){
printf("%.0f,",'$COLUMN1')
printf("%c,",$COLUMN2)
printf("%.2f,",'$COLUMN3')
printf("%c,",$COLUMN4)
printf("%.2f,",'$COLUMN5')
printf("%s,",'$COLUMN6')
printf("%s,",'$COLUMN7')
case1++
printf("%s,","case1")
printf("%d\n",case1)}}
else if ( case4 == 0 ){
if ( '$COLUMN5' == 0 ) {
printf("%.0f,",'$COLUMN1')
printf("%c,",$COLUMN2)
printf("%.2f,",'$COLUMN3')
printf("%c,",$COLUMN4)
printf("%.2f,",'$COLUMN5')
printf("%s,",'$COLUMN6')
printf("%s,",'$COLUMN7')}
case4++
printf("%s,","case4")
printf("%d\n",case4)}}
else if ( '$COLUMN3' > 0.00 ){
if ( '$COLUMN2' ~ "\-" ){
if ( case3 == 0 ){
if ( '$COLUMN5' == 0 ) {
printf("%.0f,",'$COLUMN1')
printf("%c,",$COLUMN2)
printf("%.2f,",'$COLUMN3')
printf("%c,",$COLUMN4)
printf("%.2f,",'$COLUMN5')
printf("%s,",'$COLUMN6')
printf("%s,",'$COLUMN7')}
case3++
printf("%s,","case3")
printf("%d\n",case3)}}}
else if ( '$COLUMN3' < 0.00 ) {
if ( '$COLUMN2' ~ \\- ){
if ( case2 == 0 ){
if ( '$COLUMN5' == 0 )
{printf("%.0f,",'$COLUMN1')
printf("%c,",$COLUMN2)
printf("%.2f,",'$COLUMN3')
printf("%c,",$COLUMN4)
printf("%.2f,",'$COLUMN5')
printf("%s,",'$COLUMN6')
printf("%s,",'$COLUMN7')}
case2++
printf("%s,","case2")
printf("%d\n",case2) }}}}')