Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/bin/bash
- logfile="linelog.log"
- # remember the number of lines first
- logcount_oldln=`wc -l < ${logfile}`
- logcount_oldch=`wc -c < ${logfile}`
- # do something and update the log
- date "+%Y/%m/%d %H:%M:%S" >> ${logfile}
- sleep 1
- date "+%Y/%m/%d %H:%M:%S" >> ${logfile}
- sleep 1
- date "+%Y/%m/%d %H:%M:%S" >> ${logfile}
- # check the diff
- logcount_newln=`wc -l < ${logfile}`
- logcount_newch=`wc -c < ${logfile}`
- logcount_diffln=`expr ${logcount_newln} - ${logcount_oldln}`
- logcount_diffch=`expr ${logcount_newch} - ${logcount_oldch}`
- echo "added: ${logcount_diffch} bytes, ${logcount_diffln} lines"
- # show it
- #tail -n ${logcount_diffln} ${logfile}
- tail -c ${logcount_diffch} ${logfile}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement