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

I have a CSV file with 4 columns: Itemname,Value,Description and component which is quite huge.

I have to generate a template from the above CSV file that displays only the rows of the specified component(say component='abc' which is the search criterion)

share|improve this question
Unless you edit your question to make it relevant to *nix, this will probably moved to Stack Overflow and/or closed. – Anthon Jun 24 '13 at 4:30
@Anthon how is this not relevant to *nix? As Ignacio's answer shows, awk is perfect for this. – terdon Jun 24 '13 at 14:23
@tendon I don't see why awk is perfect for this. How does awk e.g. determine the separating character used in the CSV?. This doesn't have to be the comma, something that e.g. Ignacio assumes). This now seems more a generic programming question that belongs on Stack Overflow (if not already answered there), which is why I warned the OP. – Anthon Jun 24 '13 at 15:18

Assuming there are no embedded commas, awk is perfect for this.

awk -F , '$4 == "abc" { print }' input.csv
share|improve this answer
'print' is the default action, so you may just omit it. – gelraen Jun 24 '13 at 11:03
the separating character for CSV is not always a comma, e.g. not with the defaults for some versions of Excel. – Anthon Jun 24 '13 at 16:36
Replacing the comma with something else is very, very easy. – Ignacio Vazquez-Abrams Jun 24 '13 at 20:22

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.