Copy codeThe Code is as follows :#! /Bin/bash
# Telno is used to query the number list file
# Sendsms. log is the text message sending result File
#1 indicates that the message is successfully sent.
Query_sms ()
{
> Submit_telno
> Delivered_telno
> Fail_delivered_telno
Cat telno | while read line
Do
# Determine which numbers in the telno file are successfully submitted --- save to submit_telno
Awk '{if ($1 =' $ line') print $0} 'sendsms. log> submit_telno
Done
# Determine which numbers in the telno file are successfully sent --- save to delivered_telno
Awk '{if ($2 = 1) print $0}' submit_telno> delivered_telno
# Finally, identify which numbers in the telno file fail to be submitted --- save to fail_submit_telno
Awk 'argind = 1 {a [$1]} ARGIND> 1 &&! ($1 in a) {print $0} 'delivered_telno telno> fail_delivered_telno
# Determine which numbers in the telno file are not successfully sent --- save to fail_delivered_telno
Awk 'argind = 1 {a [$1]} ARGIND> 1 &&! ($1 in a) {print $0} 'delivered_telno telno> fail_delivered_telno
}
Main ()
{
Query_sms
}
Main
Exit 0