#!/bin/sh # TailMinus.sh # 2008-07-21 # Chieh Cheng # http://www.CynosureX.com/ # GNU General Public License (GPL) Version 2, June 1991 scriptName=`echo $0 | sed s/\\\\/.*\\\\///g` perform () { skipLines=$1 file="$2" if [ -f "${file}" ] then lines=`cat "${file}" | wc -l` remain=`expr ${lines} - ${skipLines}` if [ ${remain} -gt 0 ] then tail -${remain} "${file}" fi else echo "${file} not found!" fi } usage () { echo " Usage: ${scriptName} \"skip lines\" [ \"file\" ]" echo echo " Specifying a file is optional." echo " If file is not specified, then ${scriptName} reads" echo " from the standard input." } if [ $# -gt 0 -a $# -lt 3 ] then skipLines=$1 if [ $# -eq 2 ] then file="$2" perform ${skipLines} "${file}" else tmpFile=`GetTempPathName.ksh "${scriptName}"` while read line do echo "${line}" >> "${tmpFile}" done perform ${skipLines} "${tmpFile}" rm "${tmpFile}" fi else usage fi