regex - To remove lines from a csv which have only commas -


i have file has lines have commas, , no data. issue lines not have fixed number of commas. data may below-

99,abc,123,, bcd,123,th ,,bcd,123,th ,,,,bcd,123,th ,,, ,,,,, 

the output should like

99,abc,123,, bcd,123,th ,,bcd,123,th ,,,,bcd,123,th 

i have remove lines have commas.

try single grep follows.(negating lines have started comma , till end have comma, in commands same logic used)

grep -v '^,*$'  input_file 

try awk solution follows.

awk '!/^,*$/'  input_file 

try sed solution on same.

sed -n '/^,*$/d;p'  input_file 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -