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 - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -