bash - replace varying number of spaces in file with single space -


i have list of files have columns separated varying number of spaces. how can sed or similar each column separated single space or tab?

i tried:

 sed 's/ \+ /\t/g' file > tmp  sed "s/\ /\t/g" tmp > file 

but r complained

line 526 did not have 11 elements 

you use tr

tr -s < filename 

or sed

sed -e 's/ \+/ /g' filename 

inline sed

sed -i.bak -e 's/ \+/ /g' filename 

Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -