if["$UID"-ne"$ROOT_UID"]#Check whether the user uid is 0. If the script continues to execute, if not, exit and return the echo statement
then
echo"Must be root to run this script."
exitone
fi
cd$LOG_DIR||#Enter the/tmp/log directory. If not, you will be prompted that there is no such directory. If there is a script, continue
{
echo"Can not change to necessary directory.">&2
exit 1
}
if [ -f "messages" ];#If there are messages in the/tmp/log directory, it will be cleared. If there are no files, it will be pushed out.
then
cat/dev/null>messages&&echo"Logs cleaned up."
exitzero
else
echo"Can not find this file."
exitone
fi
Statement: This article is original by BYRD (based on GNU bash, version 4.1.2), and reprinting without permission is prohibited!SourceByrd's Weblog-https://note.t4x.org/code/empty-file-content/
Statement: unless otherwise specifiedByrd's BlogThe content is original. Reproduction without permission is prohibited!For details, please readCopyright Statement!