awk - I want to check the numbers in the 1st column is equal to 2nd column -
i want check numbers in 1st column equal 2nd column, , 1st column should starting abc , ending def , number between these should matching 2nd column.
can me here please.
my input:
abc12345def |12345 |23132331331|
abc95678def |45678 |23132331331|
abc87887def |86187 |23132331331|
abc89043def |89043 |23132331331|
output should be:
abc12345def |12345 |23132331331|
abc89043def |89043 |23132331331|
i'm trying use foollowing one, it's not working. awk -f '|' '($1 !~ /abc+[$2]+def/)' whtfile.txt > qc2valid.txt
this should work requirement:
awk -f'|' '{s=$2;sub(/\s/,"",s)}$1 ~ s' input abc12345def |12345 |23132331331| abc89043def |89043 |23132331331|
the problems in codes:
- you cannot concatenate strings in awk
+
- you cannot concatenate strings in awk between
/.../
, static regex expression - you should use
~
instead of!~
, requirement described. - your column 2 has empty strings, should remove them before matching
Comments
Post a Comment