I have a comma-delimited giant file that was exported from a database. The file has this format

10-Jan-2000,344,13,21,2,55,3,"rose garden" ,3444,32
11-Jan-2000,324,3,1,21,5,23,"space green fox" ,3444,11
12-Jan-2000,34,23,31,22,5,34,"bourbon mars" ,3444,88

Notice that the color field is surrounded by quotes and has a space at the end. Don't ask me why.

I would like to end with a file that is just this:


what magic command should I type on terminal to get rid of the date, color, type and reference on all lines of that txt file?

  • 4
    cut -d, -f2-7 – Stéphane Chazelas Jan 18 '14 at 18:22
  • man, I love you. You are a genius!!!!! Please add this comment as an answer! – Duck Jan 18 '14 at 18:31
  • FYI, the format is called CSV (Comma Separated Values). – goldilocks Jan 18 '14 at 18:32
cut -d, -f 2-7 filename


awk -F, '{OFS=","; print $2,$3,$4,$5,$6,$7}' filename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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