I'm unable to count the number of records and remove new line characters which is present in between a single record and append this file output to another code. Csv file looks like
RandomName,FileName,Date,OwnerName
"f","df",10/12/1298,"dgds"
-13,"fg
dhd
fd
f",10/22/1029,"dvg
tr
-456
3gf"
"123","fd13",13/23/1245,"13
sdg
fsdg"
dv,"Df",12/12/3455,"adf"
Expected Output
RandomName,FileName,Date,OwnerName
"f","df",10/12/1298,"dgds"
-13,"fgdhdfdf",10/22/1029,"dvgtr-4563gf"
"123","fd13",13/23/1245,"13sdgfsdg"
dv,"Df",12/12/3455,"adf"
The file is 132GB in size.I'm using this solution-
perl -0777 -pe 's/((?:,"|(?!^)\G)[^",\n]*)\n/\1/g; s/,\n/,/' "${dir}" | wc -l
But Its throwing kernel soft lockup error. I have shell/awk/perl in my server. My File can contain-
- any number of records
- size <= 132 GB
- file can contains special characters.($,@,#,*,-,_,%)
- new line character can occur more than once in a single record.
Kindly help me in finding solution for printing the output to console and to another csv file as well. Thanks in advance.