Can anyone help to remove the line in file based on delimeter(Comma), Incase if line contain less number of columns or Bad records , Need to delete those.Input File:a,b,c,da,b,d,fc,da,v,b,hd,e,v,nIn the above file if the delimeter is less than 4 than i have to delete the line from the file.Output File :a,b,c,da,b,d,fa,v,b,hd,e,v,nThe below command gives me number of delimeter in a line , How can i delete if that not equal to 4,egrep -iv '' file.csv | awk -F',' '{print NF}' Thanks.
How to remove line based on Delimeter in perl / Shell?
shell;sed;awk;perl
With perl:$ perl -F, -i.bak -ane 'print if @F > 3' fileWith perl > 5.20, you can use -F without -a and -n (-F implies -a and -a implies -n).Or you can use sed:$ sed -i.bak -e '/\([^,]*,\)\{3,\}/!d' file