bash - How to remove empty rows from text file -
i have text file [end-of-line-characters in square brackets].
clearly somethings wrong here , want remove empty lines. how can this?
i prefer bash solution, others welcome.
717016|2026493|88650639|agridex|carrier|nr||v/v||nr|||1||nr||nr||nr[cr][lf] 717016|2026493|88650639|agridex|carrier|nr||v/v||nr|||1||nr||nr||nr[cr][lf] 717018|2026494|67685|sulfinyl bis(methane)|carrier|nr||nr||nr|||nr||nr||nr||10% of carrier solution[cr] [cr][lf] [cr][lf] 717019|2026494|57556|1,2-propanediol|carrier|nr||nr||nr|||nr||nr||nr||40% of carrier solution[cr][lf] 717016|2026493|88650639|agridex|carrier|nr||v/v||nr|||1||nr||nr||nr[cr][lf]
this did not work (dont know why..):
sed -i '/^$/d' file.txt
update desired output is
717016|2026493|88650639|agridex|carrier|nr||v/v||nr|||1||nr||nr||nr[cr][lf] 717016|2026493|88650639|agridex|carrier|nr||v/v||nr|||1||nr||nr||nr[cr][lf] 717018|2026494|67685|sulfinyl bis(methane)|carrier|nr||nr||nr|||nr||nr||nr||10% of carrier solution[cr][lf] 717019|2026494|57556|1,2-propanediol|carrier|nr||nr||nr|||nr||nr||nr||40% of carrier solution[cr][lf] 717016|2026493|88650639|agridex|carrier|nr||v/v||nr|||1||nr||nr||nr[cr][lf]
so third line ends [cr][lf] , lines 4 + 5 removed.
use \r
represent lf:
sed '/^\r$/d' file
or, run dos2unix
on file rid of linefeeds.
Comments
Post a Comment