I have a text file which consists of tab delimted fields terminated with a CR/LF. Before the CR/LF an extra tab has been inserted effectively creating a blank field at the end of every line.

I would like to remove this trailing tab from the file. I can't simply replace any occurrence of two consecutive tabs with a single tab as some fields may be intentinally blank, some of the files have 50+ fields with potentially 8 fields in a row being blank.

I have the following Tools at my disposal on a Win2K3 server

Anything in GnuWin32 Batch files

At a push I could install Perl or Python.

I think the correct solution is to use SED but I can't work out how to use it.

field1 <tab> field2 <tab> field3 <tab><tab> <cr><lf>
link|improve this question
feedback

1 Answer

up vote 2 down vote accepted
sed 's/\t$//' somefile.tsv
link|improve this answer
Thank you, this works perfectly. – JamieDainton Dec 2 '10 at 8:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.