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 directory with a group of CSV files. All files have the same column headers. I need to extract values in a certain column from all files.

The common part in files names is OCS_mobfwref-oam_d01_2014080*

share|improve this question

closed as unclear what you're asking by derobert, Ramesh, Karlson, jasonwryan, Braiam Aug 7 '14 at 21:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Provide a sample of the data in the files, to see what the delimiter is, the number of columns, etc... Also, what have you tried so far? – jimm-cl Aug 7 '14 at 14:12
Hi and welcome to the site. Next time, please give us an example of your input and the output you want. It makes it much easier to understand what you need. – terdon Aug 7 '14 at 20:04
up vote 1 down vote accepted

To extract from the 3rd column for example, you can do:

cut -d',' -f3 OCS_mobfwref-oam_d01_2014080* 

This only works if there are no un-escaped comma's!

If you want to remove the headers, do:

sed 1d OCS_mobfwref-oam_d01_2014080* | OCS_mobfwref-oam_d01_2014080* 
share|improve this answer
removing headers isn't working – Mohamed Yasser Aug 7 '14 at 14:25
thanks so much btw – Mohamed Yasser Aug 7 '14 at 14:49

the same in awk, with a head in first 2 lines, extracting the third field, assuming filed separator is ',' (comma).

 awk -F, 'NR>2 { print $3 ; }' *.csv
share|improve this answer

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