Hi,
I don't script often enough to know how to do this, and I can't seem to find a right example online. I have a csv output from an old, old system (Win2K???), from which I want to extract only certain fields. Initially I came up with something like this:
cat file1 | awk -F '"' '{print $8 " " $12 " " $16}'
The csv file contains some data like this:
<file1>
"pippo","is fat","last","Cruise","first","Tom","UID","1234","more blah"
"monky","looks funky","last","Jones","first","Catherine Zeta","UID","2345","more blah"
"lion","rules savannah","last","Baldwin","first","Alec","UID","3456","more blah"
So the output would be:
Cruise Tom 1234
Jones Catherine Zeta 2345
Baldwin Alec 3456
But I realized later that the csv file may contain lines that do not conform to the above format when a user has more than one UID. The additional UID's are appended following the first appearance to that user name like this:
"pippo","is fat","last","Cruise","first","Tom","UID","1234","is 50 years old"
"monky","looks funky","last","Jones","first","Catherine Zeta","UID","2345","is still hot"
"lion","rules savannah","last","Baldwin","first","Alec","UID","3456","his brother sued costner and lost"
"taco","4567","blah","age of rock"
"chili","5678","blah","flopped bit time"
"mojito","tastes awesome","last","Brand","first","Russell","UID","6789","didn't deserve katy"
I am trying to script it so that I will get an output like this:
Cruise Tom 1234
Jones Catherine Zeta 2345
Baldwin Alec 3456
Baldwin Alec 4567
Baldwin Alec 5678
Brand Russell 6789
I would think I can do this with if statement and while loop? Users with multiple UID's can appear several times randomly, but one user with multiple UID's appear as a sequential block and one time only in the initial csv file.
If someone can point me to the right direction, I would greatly appreciate it.
Regards,
Bash Noob...