【將資料直接輸出到檔案】
$ vim arr.txt
1034 7:26
1025 7:27
1101 7:32
1006 7:45
1012 7:46
1028 7:49
1051 7:51
1029 7:57
1042 7:59
1008 8:01
1052 8:05
1005 8:12
-> vim 命令模輸入 “:wq” (存檔離開)
$ vim reformat1.awk
BEGIN {
print “ID Number Arrival Time” > “today_rpt1”
print “========================” > “today_rpt1”
}
{ printf(“%6s %8sn” , $1, $2) > “today_rpt1” }
-> vim 命令模輸入 “:wq” (存檔離開)
$ awk -f reformat1.awk arr.txt
$ cat today_rpt1
ID Number Arrival Time
========================
1034 7:26
1025 7:27
1101 7:32
1006 7:45
1012 7:46
1028 7:49
1051 7:51
1029 7:57
1042 7:59
1008 8:01
1052 8:05
1005 8:12
【資料參考來源】