$ cat ff
./res/values/strings.xml:1293: <string name="sub1LineNumber">Sub1 Number :</string>
./res/values/strings.xml:1302: <string name="xdivert_partial_set">XDivert has been set only for 1st subscription</string>
./res/values/strings.xml:1870: <string name="set_sub_1">Subscription 1: </string>
./res/values/strings.xml:1860: <string name="sub_1">SUB 1</string>
for f in $(cat ff |awk -F : '{print $1" +" $2}'); do echo $f; done
./res/values/strings.xml
+1293
./res/values/strings.xml
+1302
./res/values/strings.xml
+1870
./res/values/strings.xml
+1860
我想以$ 1 + $ 2的格式在一行中打印$ 1和$ 2,但打印在上面,出了什麼問題?爲什麼在兩行中打印awk?
@Dan您應該將其作爲答案發布。 – Barmar
不需要將文件'cat'到'awk'。正確的語法:'awk -F:'{print $ 1「+」$ 2}'ff' – Jotne
真的夠了,它不是必需的(但是它是否是首選的樣式也是有爭議的;我將討論這個不是堆棧溢出)。在這種情況下,我只是爲了最小化地編輯原文。 – danfuzz