Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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, Evan Teitelman 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
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.