|
发表于 2019-4-27 22:50:58
|
显示全部楼层
awk is one of the best tools, if not the best, to work with tabular data. 1 B4 N3 }- [! u+ w3 C$ A! q
on the other hand, powerful it is, regular expression is overly used in the wrong places. 2 ]0 M3 [9 x/ A8 g9 `1 A
% i2 y. a" Q9 i$ f
To solve your problem with awk,, v! q" a2 P* |% Q& m+ o, Z
awk '{for(i=3; i<=NF; i++) if($i==$2) $i = "" } { print }' 2nd-col.txt > 2nd-cleaned.txt
8 s* ]9 N h0 e3 f3 D9 q4 ]
# {4 A! m0 l- S/ n1 Z9 xsuppose 2nd-col.txt is your original file and 2nd-cleaned.txt is your cleaned file.
. l0 ]% X! E) S' \I've uploaded a screenshot, but I'm not sure whether it shows correctly.0 O6 u" _! }6 l, W1 f; K. F
4 Y4 U( l# Z8 e* n) m |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?免费注册
x
|