|
发表于 2019-4-27 22:50:58
|
显示全部楼层
awk is one of the best tools, if not the best, to work with tabular data.
' J+ P4 Z- [$ E. U0 h2 F) J- Jon the other hand, powerful it is, regular expression is overly used in the wrong places.
+ [5 j7 {( [- v E+ p
- d3 v, G* D* G" |To solve your problem with awk,
5 U* r) J# T- Z; X0 _awk '{for(i=3; i<=NF; i++) if($i==$2) $i = "" } { print }' 2nd-col.txt > 2nd-cleaned.txt
2 Q0 Z6 W8 E2 I6 n" |6 w& o( V1 j2 F7 \8 P6 W" g; \9 v6 \! [
suppose 2nd-col.txt is your original file and 2nd-cleaned.txt is your cleaned file., v$ z$ Y4 X% P5 l6 i3 D4 X
I've uploaded a screenshot, but I'm not sure whether it shows correctly.- ^) {9 I1 h! G3 n; q, v
, ^0 r, |! ]. Y& ^# j |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?免费注册
x
|