loops

Hi All

I have some directories on our server which are containing .csv files. i need to print value of cell "B2" from those csv files. Please advise.

I have tried head command as example: head -2 */Book_Collection_Report_1_-_Collection_Requests_trials.csv | sed -n "3p" | awk -F"," '{print$1}'
but it given me output of first file's value..

thanks in advance
Yash :mad:

assuming "*/Book_Collection_Report_1_-_Collection_Requests_trials.csv" will result the csv files you need,

awk -F, 'FNR==2 {print $2}' */Book_Collection_Report_1_-_Collection_Requests_trials.csv

It worked.... :b:

---------- Post updated at 03:36 PM ---------- Previous update was at 03:19 PM ----------

When i print cell value of "B2" it gives result fine. But in some cases cell B2 having "," comma also example- "ALBERT SLOMAN LIBRARY, UNIVERSITY OF ESSEX - 8073". It split it into two parts.

Query--"awk -F, 'FNR==2 {print $1}' */Book_Collection_Report_1_-_Collection_Requests_trials.csv"

Please advise.

What output you are getting? I didn't understand the split thing.
The example you provided contains a space after comma. so there would be a leading space in the output.

if cell B2 having comma, that means field 2 is null, in that case what is the required output? comma or null?

Actually we needed the cell value with comma also as i example below.... I have made the changes in your query at my end & now i m getting perfect result which i need....
Anyway many thanks for your advise promptly.

awk -F,',' 'FNR==2 {print $1}' */Book_Collection_Report_1_-_Collection_Requests_trials.csv