2013-11-21 89 views
0

我已經經歷了一些簡單的在工作中的bash腳本別人寫的一個月前,我發現這條線:

| awk -F'AUTO_INCREMENT=' 'NF==1{print "0";next}{sub(/ .*/,"",$2);print $2}' 

有人能幫我解釋簡單的話這條線。謝謝!

+0

你爲什麼要改變原來的問題內容?看來你想發佈一個編輯問題,但隨着你也試圖編輯我的答案。 – jkshah

回答

2
awk -F'AUTO_INCREMENT=' '  # Set 'AUTO_INCREMENT=' as a field separator 
    NF==1 {     # If number of fields is one i.e. a blank line 
     print "0";    # print '0' 
     next     # Go to next record i.e. skip following code 
    } 
    { 
     sub(/ .*/,"",$2);  # Delete anything after a space in the second field 
     print $2    # Print the second field 
    }' 

樣品輸入

AUTO_INCREMENT=3 

AUTO_INCREMENT=10 20 30 foo bar 

輸出

3 
0 
10 
相關問題