in my Linux machine I have the file orig-file.txt
this file include now 4 fields but they could be less or more ( this file generate by other application )
I need advice - what the best option to translate the orig-file.txt to file as output-file.txt file ( could be by shell script or awk ..etc)
the target to translate the orig-file.txt file to output-file.txt ( as my example below ) while need to remember that in the orig-file.txt number of fields can change to more or less
What the best option to do that? ( I will happy to get real example )
orig-file.txt
CREATE_TIMESTAMP TELEPHONE_NUMBER ID TYPE
------------------- -------------------- ---------- -----------------
24-09-2009 16:17:45 33633333333 20 other_mmm_phone
24-09-2009 17:45:07 33644444444 20 other_mmm_phone
07-10-2009 10:45:49 12312312312 20 legacyphone
07-10-2009 11:46:38 59320000043 20 other_mmm_phone
output-file.txt
CREATE_TIMESTAMP -> 24-09-2009 16:17:45
TELEPHONE_NUMBER -> 33633333333
ID -> 20
TYPE -> other_mmm_phone
---
CREATE_TIMESTAMP -> 24-09-2009 16:17:45
TELEPHONE_NUMBER -> 33633333333
ID -> 20
TYPE -> other_mmm_phone
---
solution by AWK but not work -:(
awk 'FNR == 1 {
for (i = 1; i <= NF; i++) { header[i] = $i } FNR > 2 { for (i = 1; i<= NF; i++) { print header[i], "->", $i } printf "\n\n\n%s\n\n\n", "--------" }' output.csv
awk: syntax error near line 5
awk: illegal statement near line 5