Delete some lines in a file

hi i need to delete 3 lines (last 3 lines ) in a file

for ex :

>cat file
1
2
3
4
5
abc
def
ghi

i hav to delete last 3 line in above file

please help me

 head -3 file 

---------- Post updated at 12:26 AM ---------- Previous update was at 12:13 AM ----------

#!/bin/bash

OLDIFS=$IFS
IFS=$'\n'
var=($(<file))
len=${#var[*]}
for((i=0;i<$((len-3));i++))
do
  echo "${var[$i]}"
done
IFS="$OLDIFS"

# sed -n "1,$(echo "`sed -n '$=' infile` - 3" |bc) p" infile
1
2
3
4
5

I love how many different ways there are to do the same task for something like this...

head -n -3 is the best option...

#!/usr/bin/perl

while (<>) {
$x = $x . $_;
}
$x =~ sm/\n.*\n.*\n.*$//g;
print $x;

can u explain this cmd

sed -n "1,$(echo "`sed -n '$=' al` - 3" |bc) p" infile

i can't understand whr we hav to give file name

# echo "`sed -n '$=' infile` - 3" |bc --->
sed -n '$=' infile ---> only print last line number ---> equal 8
and minus 3 eqaul 5
and sed -n "1,5p" --> only print 1 between 5 number line