#!/bin/bash
#author: Zjmainstay
#website: http://zjmainstay.cn
#filename: taillog
#usage:
#first time: $path_to_this_shell/taillog.sh
#other time: $taillog or $taillog 2014_04_15 for specified day log
#create quick command
LOG_PATH="/var/logs"
FILE_PATH=$0
pwd
FILE_DIR=`dirname $0`
if [ $FILE_DIR == '.' ]
then
FILE_PATH=${FILE_DIR/'.'/~}
fi
#create bin dir if not exists
if [ ! -d ~/bin ]
then
mkdir ~/bin
fi
#link current file to bin dir
if [ ! -f ~/bin/taillog ] ## "~/bin/taillog" is wrong here
then
ln -s $FILE_PATH ~/bin/taillog
fi
#tail log file if exists
if [ -z $1 ]
then
dir=$(date +"%Y_%m_%d")
else
dir=$1
fi
LOG_FILE=${LOG_PATH}/$dir.log
if [ -f $LOG_FILE ]
then
tail -f $LOG_FILE
else
echo "$LOG_FILE is not exists."
fi 未经同意禁止转载!
转载请附带本文原文地址:快捷查看日志的shell,首发自 Zjmainstay学习笔记




