I'm having some trouble trying to create an awk script that checks and possibly corrects every line in a text file.
Consider the example:
$ cat employee.txt
"100","Thomas","Sales","5000"
"200","Jason","Technology","5500"
"300","Mayla",
"Technology","7000"
"400","Nisha","Marketing","9500"
"500","Randy","Techno
logy","6000"
"501","Ritu","Accounting","5400"
As you can see, some of the lines appear to be broken at the wrong point. The pattern should follow as such:
$ cat employee.txt
"100","Thomas","Sales","5000"
"200","Jason","Technology","5500"
"300","Mayla","Technology","7000"
"400","Nisha","Marketing","9500"
"500","Randy","Technology","6000"
"501","Ritu","Accounting","5400"
So I was wondering if there was a way in Awk to determine if the pattern isn't being followed, such as by verifying the number of commas in every line, and then backspacing the broken lines.
I receive files like this containing hundreds or thousands of rows, so manual work to fix all the broken lines is tedious.
I'm creating a control file to load data into a table using SQLLDR, but I get errors because the text file contains broken lines. So my solution is to fix every line by script.
Any thoughts? Script doesn't have to be in Awk.