2 of 3 Typos.

As an alternative without the problem of spaces (POSIX):

$ sed -n '$=' ~/myfile.txt

Captured in a variable:

$ nl=$(sed -n '$=' ~/myfile.txt)
$ echo "1-$nl-"
1-100-

Note that sed counts the last line even if it doesn't end in a newline character (as it should in a properly formatted text file).


Another alternative (not that I recommend using it):

$ nl=$(cat ~/myfile.txt | tr -dc '\n' | tr '\n' 'x')
$ echo "1-${#nl}"
1-100