Bash: head: Remove last N lines from file 3

head -n -$N inputFile > outputFile

Where $N is the number of the line from the end which you want to stop printing.
For example if you want to delete the last line you must issue the following:

head -n -1 inputFile > outputFile

Bash: Read a file, line by line

The following script will accept from the keyboard a filename, later it will read it and process it line by line.
In this example we will just number the lines, print them and count the total number of lines in the file.

echo Enter the Filename to process
read filename
while read line
	lineNumber=`expr $lineNumber + 1`;
	echo $lineNumber - $line;
echo "Total Lines Number: $lineNumber";