1.示例
// 写数据到文件
char buffer[128] = {0};
int tmp;
float tmp1;
sprintf(buffer," echo %d , %.2f >> /home/fmsh/test.txt",tmp,tmp1);
system(buffer);
2.配置环境变量
上电后检查文件的行数,若被写的文件超过10000行,则删掉5000行
msgLens=`sed -n '$=' /home/fmsh/test.txt`
echo " [test]: ${msgLens} "
if [ ${msgLens} -gt 10000 ];
then
echo "Delete msg"
sed -i '1,5000d' /home/fmsh/test.txt
fi