Remove blank columns from a tab delimited text file

Hello,

I have some tab delimited files that may contain blank columns. I would like to delete the blank columns if they exist. There is no clear pattern for when a blank occurs.

I was thinking of using sed to replace instances of double tab with blank,
sed 's/\t\t//g'

All of the examples I have seen are two consecutive blanks columns. I don't believe that there will be instanced of more than two blank cols, but it's hard to say. It would be nice to have code that was more generic.

LMHmedchem

How about: tr -s '\t' < inputfile > outputfile

One, two, three four, or three hundred tabs in a row will become one tab.

2 Likes

Thanks, that did the trick.

LMHmedchem