Binary file syslog matches
My RPi3 just missed the six month uptime mark due to a power failure that also caused some minor data corruption. Interestingly, the RPi powered up before the network equipment was online and thus failed to synchronize the time. I didn’t notice immediately but things go sour quickly when a Internet connected device believes the date to be Jan 1 1970.
The data corruption issue became evident when automated tasks using the grep command no longer returned any output. Manually grepping syslog returned the “Binary file syslog matches” message. This translates to grep considering syslog to be a binary file. Upon inspection, the syslog had become filled with ascii NUL characters (^@^@^@) which I needed to clear out. I’ve recently found that the easiest way to handle this is by using the sed command.
Identify the NUL character and pipe to cat using the nonprinting switch:
sed -n '/\x0/p' /var/log/syslog | cat -v
Remove all occurrences of the NUL character
sed -i 's/\x0//g' /var/log/syslog