|
发表于 2019-4-27 22:50:58
|
显示全部楼层
awk is one of the best tools, if not the best, to work with tabular data. ! z/ i+ b! E: E
on the other hand, powerful it is, regular expression is overly used in the wrong places.
) @/ y8 C8 F' z: i |+ }0 b1 L j0 t$ D* I J1 J2 j7 o
To solve your problem with awk,+ \0 ]; I9 Q9 V! V) D* g
awk '{for(i=3; i<=NF; i++) if($i==$2) $i = "" } { print }' 2nd-col.txt > 2nd-cleaned.txt
2 ?' Q/ t% P: D3 W' r* S7 Z$ E1 ~* ~, I. k7 F4 ~3 E$ S8 [! V
suppose 2nd-col.txt is your original file and 2nd-cleaned.txt is your cleaned file.
d- C6 r8 Q& l/ GI've uploaded a screenshot, but I'm not sure whether it shows correctly.
# c% r' k* p5 q+ T, V! Z \4 B4 r: q. b+ k, E2 D& ?
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?免费注册
x
|