當前目錄下有文件log,內容大致如下
2015-11-29 54144a04ad4asd044a4s CSeq:1 INVITE sip:2112@sipserver.com:5060 SIP/2.0
2015-11-29 54144a04ad4asd045457 CSeq:1 INVITE SIP/2.0 200 OK
將此log文件做精簡,創建文件minilog內容如下
1 INVITE sip:2112@sipserver.com:5060 SIP/2.0
1 INVITE SIP/2.0 200 OK
Shell腳本代碼如下
#!/bin/sh
function shortLog() {
while read line
do
echo ${line#*CSeq:} >> $2
done < $1
}
shortLog log miniLog