#!/bin/bash
diarypath='/home/quanwei/documents/diary/riji.riji'
tempfile=`mktemp -u`
vi $tempfile
if [ -f $tempfile ]; then
echo `date` >> $diarypath
cat $tempfile >> $diarypath
rm $tempfile
echo 日记写入
else
echo '文件为空而取消日记' ;
fi
来源:oschina
链接:https://my.oschina.net/u/870108/blog/393316