我試圖通過bash腳本提交git修補程序。這不是一個混帳問題!這是我想要做的,我有一個目錄中的文件列表。我想要逐個讀取這些文件,並從中提取特定的行,然後進行提交。 這是我到目前爲止;使用egrep正則表達式來捕獲部分行
patches=/{location}/*.patch for patch in $patches do echo "Processing $patch file..." git apply $patch git add --all git commit -m | egrep -o "(^Subject: \[PATCH [0-9]\/[0-9]\].)(.*)$" $f echo "Committed $patch file..." done
無法讓egrep正則表達式正常工作以傳遞適當的提交消息。 以下是補丁文件中的示例行;
..... Subject: [PATCH 1/3] XSR-2756 Including ldap credentials in property file. ......
我只是想捕捉 「XSR-2756包括財產文件LDAP憑證。」並用作git的提交描述。
同意。如果您不使用GNU grep,請使用awk代替'awk'{print gensub(/(^ Subject:\ [PATCH \ d/\ d \]。)(。*)$ /,「\\ 2」,「 g「)}'' – nachito
'awk'{sub(/^Subject:\ [PATCH \ d \/\ d \] ./,」「);打印}''有點簡單。 –
感謝您的回答 – aug70co