我使用How to restrict grep to search only the one column within a CSV file, but to output matching lines in their entirety?的答案用awk搜索特定的列,然后输出匹配的行,例如:
awk -F@ "{if (\$2 ~ /$find_me/ ) { print \$0; } }" <input_file>
$find_me
的行?答案 0 :(得分:2)
你可以试试这个:
awk -F@ -v pattern="$find_me" '$2 ~ "^" pattern "$"' input.txt
或者
awk -F@ -v pattern="^$find_me\$" '$2 ~ pattern' input.txt