我有一個文件,其頭部記錄後跟詳細信息行。我希望使用awk將標題中的單詞標記爲文件中的後續行。每個標題記錄都有一個特定的單詞「標題」。使用awk將頭文件中的第一個單詞添加到文件的所有後續行中
我的樣本文件
h1_val header
this is line 1 under header set1
this is line 2 under header set1
this is line 3 under header set1
this is line 4 under header set1
h2_val header
this is line 1 under header set2
this is line 2 under header set2
this is line 3 under header set2
this is line 4 under header set2
我的輸出應該像
h1_val this is line 1 under header set1
h1_val this is line 2 under header set1
h1_val this is line 3 under header set1
h1_val this is line 4 under header set1
h2_val this is line 1 under header set2
h2_val this is line 2 under header set2
h2_val this is line 3 under header set2
h2_val this is line 4 under header set2
請幫
謝謝!
感謝ghoti看來,如果線是純如果我輸入看起來像逗號分隔並用雙引號工作正常.. ......應該awk的是什麼樣的變化
"h1_val","header word"
"this is line 1","under header","set1"
"this is line 2","under header","set1"
"this is line 2","under header","set1"
"this is line 2","under header","set1"
"h2_val","header word"
"this is line 1","under header","set2"
"this is line 2","under header","set2"
"this is line 2","under header","set2"
"this is line 2","under header","set2"
謝謝!
爲什麼你沒有在第一位指定這些條件? – 2012-07-11 03:57:46