问题
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