Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I am using a mac and I have a CSV file delimited by tabs. I want to just remove all the content between the 2nd and 3rd tabs or replace it with something like "XXXX". Is there a command for this?

share|improve this question

marked as duplicate by jasonwryan, Anthon, slm, rahmu, paraxor Jul 30 '13 at 23:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
The quickest way would be using a text editor that allows vertical selection (sublime, text mate), but I'm guessing you want to do this from the command line, in which case sed is your friend –  spuder Jul 30 '13 at 19:20
    
@spuder, vim can do vertical selection too, but in this case the fields may not be aligned. Can editors deal with that? A spreadsheet would be more straightforward. –  Paulo Almeida Jul 30 '13 at 21:00

2 Answers 2

up vote 1 down vote accepted

Using cut:

cut --complement -f 2-3 <file>
share|improve this answer

Try awk

awk '{$3="XXXXX"; print $0}' infile > newfile
share|improve this answer

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