Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I would like to write a script (probably AWK printf related) that will take my delimited file, remove some unwanted fields and add some additional fields througout the file:

For example:


I want to keep fields 1,2,4,7 and add in two empty fields between fields 4 and 7 so the output would look like:


Is this possible?

share|improve this question
up vote 1 down vote accepted

You can do that with:

awk -F , '{ printf "%s,%s,%s,,,%s\n" , $1 , $2 , $4 , $7 }' file
share|improve this answer
Perfect thanks!!! – mattm123 Oct 29 '10 at 11:37

If you already have the delimited file, than this should be very easy. At the top, it should list all of the fields, just take out the ones you do not want, and insert the ones you do want. I warn you though, with will effect all of the entries that are currently in the file. I would use a program like Excel or open offices version of Excel to do this with a file that currently has entries.

If you need anymore help, please comment, I will try to help as much as possible.

Good Luck-

share|improve this answer
oh no i need to perform this in shell scrip, no excel for me unfortunatly – mattm123 Oct 28 '10 at 15:30
Sorry, I saw Unix and didn't know if you used WINE, or if you were just going to use VI. – David Oct 28 '10 at 17:26

Your Answer


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.