【发布时间】:2016-11-10 14:05:17
【问题描述】:
我在这样的文件中有一个字符串:
47:2016-10-25 20:24:21 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
301:2016-10-26 08:01:01 - [HSM ]Handle Identity Request. Send Identity Response. timeout: 1550s
我有一个输入字符串为日期“2016-10-25”,另一个输入字符串为“处理身份请求。发送身份响应”。
我想找到号码。文件中存在的字符串。我试过这个:
total_attempt=$(grep -c "$i\|\[HSM \]Handle Identity Request. Send
Identity Response. timeout: 1550s" $file_name
我相信 |在上述语法中将不起作用。
注意:$i 是输入的日期
输出应该是这样的:
2016-10-25: = attempts = 2
但这不起作用。
Sed 命令会有所帮助,但我不确定如何?
【问题讨论】: