Quote:
|
Originally Posted by ganesh123
Hello friends,
I want to remove 3 header lines and 4 trailer lines,
I am using following , is it correct ?
Code:
sed '1,3d';'4,$ d' filename
|
Is it correct? Run it and see.
To remove an arbitrary number of lines from both hte top and bottom of a file, use my topntail command:
Code:
b=
e=
while getopts b:e: opt
do
case $opt in
b) b=$OPTARG ;;
e) e=$OPTARG ;;
esac
done
shift $(( $OPTIND - 1 ))
case $b$e in
*[!0-9]*) exit 5 ;;
esac
if [ ${e:-1} -eq 0 ]
then
sed "1,${b:-1}d" "$@"
else
awk 'NR > b + e { print buf[ NR % e ] }
{ buf[ NR % e ] = $0 }' b=${b:-1} e=${e:-1} "$@"
fi