我正在嘗試計算no。在給定日期範圍內打印的線條。得到沒有。爲日期範圍打印的行數
這是我的輸入和輸出:
grep -inr "\[HSM \]Handle Identity Request. Send Identity Response. timeout: 1550s" *ActNac*
ActNacd.txt:47:2017-01-02 09:10:13 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2016-12-20_20-39-18.txt:171:2016-12-19 13:23:48 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2016-12-20_20-39-18.txt:217:2016-12-19 14:27:26 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2016-12-26_09-44-47.txt:47:2016-12-25 19:26:13 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2016-12-26_09-44-47.txt:91:2016-12-25 20:30:38 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2016-12-27_07-32-25.txt:47:2016-12-26 11:08:28 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2016-12-27_18-06-29.txt:47:2016-12-27 07:35:55 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2016-12-30_08-22-16.txt:48:2016-12-28 18:04:19 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2017-01-02_06-56-52.txt:47:2016-12-30 08:24:19 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
old_ActNacd_2017-01-02_09-07-23.txt:47:2017-01-02 06:59:33 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
我想找到沒有。自2017年12月20日至2017年12月30日之間印刷的線條。
開始日期和結束日期都沒有確定,所以如果我使用sed命令狀
grep -inr "\[HSM \]Handle Identity Request. Send Identity Response. timeout: 1550s" *ActNac* | sed -n '/2016-12-20/,/2017-12-27/p'"
,但如果我提供的輸入,如:
grep -inr "\[HSM \]Handle Identity Request. Send Identity Response. timeout: 1550s" *ActNac* | sed -n '/2016-12-19/,/2017-12-27/p'"
它不給任何輸出,因爲開始日期與任何行不符合輸入日期。沒有日期2016-12-19的日誌文件。
是否有任何其他方式使用sed/awk/grep命令獲取輸入日期範圍內的行數。
要獲得日e從任何東西輸出的行數,只需將輸出輸出到'wc -l'。 –
我必須從20-27/12過濾掉適當的行然後得到我要使用wc -l –