I have some corrupted .txt files, in which I need to fix first 3 lines.
How it should be:
Template=1.0
SKU, Standard Price, Minimum Age Recommendation
sku, standard_prive, mg_recommendation
After it got corrupted:
Template=1.0
SKU, Standard Price, "Minimum Age Recommendation
"
sku, standard_prive, mg_recommendation
in some cases:
Template=1.0
SKU, Standard Price, "Minimum Age
" Recommendation
sku, standard_prive, mg_recommendation
I need to check if first line starts with quote mark, if yes, then merge 3rd line with second line.
otherwise I can't import the file as it fails to find proper headings in 3rd line.
AWK is preferred, because I already performing other task with it. I can't figure out, how I could check 3rd line value while I'm on 2nd value in the awk loop.
Solution preceeds records that don't start with
"
with a newline. Downside is that the last record ends without a newline.END{print ""}
fixes that.