On Linux I have the file orig-file.txt. This file include 4 fields now, but they could be less or more (this file is generated by other application).
What is the best option to translate the orig-file.txt to a file like output-file.txt file (it could be with a shell script or awk, etc.)
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
---
example from awk lang -( but its not work -:(
# awk 'NR>2 {
> printf "\
> %-16s -> %s\n\
> %-16s -> %s\n\
> %-16s -> %s\n\
> %-16s -> %s\
> \n\n\n---\n\n\n",\
> "CREATE_TIMESTAMP", $1" "$2,\
> "TELEPHONE_NUMBER", $3,\
> "ID", $4,\
> "TYPE", $5}\
> ' orig-file.txt
awk: newline in string near line 2
awk: syntax error near line 3
awk: illegal statement near line 3
awk: newline in string near line 7
output-file.txtis a bad format in my eyes. It is a lot less clear to even read manually thanorig-file.txtimho. – Daniel Andersson Apr 17 '12 at 15:14