Quote:
|
Originally Posted by anbu23
Code:
#!/bin/ksh
awk -v check_val="$1" '{
if( $0==check_val) { key[$0]++ }
if(key[$0] < 2 ) print $0
}' inputfile > outputfile
|
umm..how abt this?
awk '/$1/' inputfile>temp
awk '{for ( $0 in `cat temp` )
key[$0]++
if(key[$0] < 2 ) print $0
}' inputfile > outputfile
i didnt try this out, but i hope the logic is clear. i searched for the pattern specified by $1 and stored all the matches in temp. then instead of a direct comparison with 'if', i matched $0 with all the values in temp using a for loop. rest of the logic is the same. pardon any syntactical errors.