0
1
I have a .csv file that has some values formatted as paragraphs with line breaks or sometimes bullet points.
"STAT","ID","DESC"
"UPD", "1", "Updated"
"CHG", "2", "Changed"
"UPD", "3", "Updated.
Might have to update again"
"UPD", "4", "Updated.
- once
- twice
- thrice
"
"DEL", "5", "unknown"
"DEL", "6", "Deleted
Need to restore"
I need to count the number of records, used awk like below since I knew 2nd column is unique id but returns more than I have. Above text is ofcourse dummy as I'm not allowed to share original but I tried to reflect as closely as I can.
awk '{print $2}' FS="," sample.csv | wc -l
I even printed out first column using awk '{print $1}' to check just the first column values but the output shows the starting parts of new line in paragraphs.
Please let me know if any additional info is needed and I'll update the question.
What are you doing with result? Must you use awk? If you just want the info, try nirsoft csvfileviewer – yosh m – 2015-01-12T23:07:39.410
I need to count the number of records through unix command line, as part of automating a testing task (count number of records everytime we get an updated csv from a vendor). I can open in excel and see the correct number once but since I need to automate this process in unix commandline I'm trying awk. I don't have access to any other tools/packages except the ones that are part of commandline. Like sed, grep and awk. – vchollati – 2015-01-12T23:11:49.147