confirmerror(){
trimline|awk -F ':' '{if($5 != "") print}'
}
result(){
deviceName=$($1|awk '{print $4}')
processId=$($1|awk '{print $5}'|awk -F '[^0-9]*' '{print $2}')
processName=$($1|awk '{print $5}')
description=$($1|awk '{print $6,$7,$8,$9}')
echo $deviceName
echo $processId
echo $processName
echo $description
}
confirmerror | while read line; do result $line; done
The OUTPUT of function confirmerror:
May 13 00:01:58 BBAOMACBOOKAIR2 com.apple.xpc.launchd[1] (com.apple.mdworker.bundles[12513]): Could not find uid associated with service: 0: Undefined error: 0 501
May 13 00:01:58 BBAOMACBOOKAIR2 com.apple.xpc.launchd[1] (com.apple.mdworker.bundles[12513]): Service exited with abnormal code: 78
May 13 00:02:12 BBAOMACBOOKAIR2 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.pid.mdmclient.12523): Failed to bootstrap path: path = /usr/libexec/mdmclient, error = 108: Invalid path
Need to read each line of function x, after processing, get the corresponding format output, the top is my attempt, but it failed, so I come to seek advice.
What I want:
BBAOMACBOOKAIR2
1
com.apple.xpc.launchd[1]
(com.apple.mdworker.bundles[12513]): Could not find uid associated with service: 0: Undefined error: 0 501
BBAOMACBOOKAIR2
1
com.apple.xpc.launchd[1]
(com.apple.mdworker.bundles[12513]): Service exited with abnormal code: 78
BBAOMACBOOKAIR2
1
com.apple.xpc.launchd[1]
(com.apple.xpc.launchd.domain.pid.mdmclient.12523): Failed to bootstrap path: path = /usr/libexec/mdmclient, error = 108: Invalid path