Delete lines or rows in a tab-delimited file, by number of cells in that lines or rows

喜你入骨 提交于 2019-12-13 21:17:49

问题


I want to delete lines/rows which have less then or equal to 5 columns or more than 7 colunms in txt file delimited with tab. This means I want to keep lines with just 6 columns in a tab-delimited files.

I prefer to sed and awk to do this job.


回答1:


you can try

  awk -F"\t" 'NF==6' file >temp && mv temp file



回答2:


on command line :

awk '!(NF>=7 && NF<=5)' file


来源:https://stackoverflow.com/questions/5595516/delete-lines-or-rows-in-a-tab-delimited-file-by-number-of-cells-in-that-lines-o

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!