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*

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.

  • 1
    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

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* 
  • removing headers isn't working – Mohamed Yasser Aug 7 '14 at 14:25

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

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