Get the line count from 2nd line of the file ?

Hi,

I want to get the line count of the file from the 2nd line of the file ? The first line is header so want to skip that.

Thanks.

To see the second line of a file:

cat myfile | head -2 | tail -1

To store to a value:

myval=$(cat myfile | head -2 | tail -1)
awk ' NR==2' filename

or maybe

 sed  '2,2!d' filename

This is just printing the 2nd line of the file.

Actually, I want to get the count of rows in the file starting the 2nd line.

Thanks.

awk 'END{print NR-1}' file

Regards

Since I have a file called runedit...

> linect=$(cat runedit | wc -l)
> echo $linect
508
> linect=$((linect-1))
> echo $linect
507

Try using WC command. Get the total count and subtract one.:slight_smile:

What about grep :wink:

echo $(($(grep -c '^' runedit) -1))

Beware of the Herder of Useless Cats! :smiley:

linect=$(wc -l < runedit)