Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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>
share|improve this question
add comment

1 Answer

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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