|
发表于 2019-4-27 22:50:58
|
显示全部楼层
awk is one of the best tools, if not the best, to work with tabular data. ) g0 Q: p* i- o H+ ]1 u0 @/ \& D
on the other hand, powerful it is, regular expression is overly used in the wrong places.
- J9 u. n+ P. X8 ]& D: g8 m+ t; C& t4 P3 ]% @' `
To solve your problem with awk,& b1 T' t7 u3 G y" w. R, V, n
awk '{for(i=3; i<=NF; i++) if($i==$2) $i = "" } { print }' 2nd-col.txt > 2nd-cleaned.txt
c8 P" b" d4 m( A. M; [3 Q! {0 e7 r3 a v! V1 |( ]
suppose 2nd-col.txt is your original file and 2nd-cleaned.txt is your cleaned file.
- P4 g- j( }7 m6 wI've uploaded a screenshot, but I'm not sure whether it shows correctly.
7 ~# l- i: K- h% J
8 k! {- s( f" y; H+ N( p |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?免费注册
x
|