How to 'sed' the middle line?

Hi,

If I have 90 lines and I want to print the 45th line, is there a quick sed command for this?

thx.

sed2liners

# print line number 52
 sed -n '52p'                 # method 1
 sed '52!d'                   # method 2
 sed '52q;d'                  # method 3, efficient on large files

Thanks, but would if I did not know the middle line number?

Is there a formula to figure out the middle line number?

Something like (wc -l) divided by 2 ?

thx.

echo `wc -l filename| cut -f 1 -d " "`/2 | bc

echo `wc -l filename| cut -f 1 -d " "`/2 | bc
syntax error on line 1, teletype

Thanks for the replies, but I can't get it to work. The file is a list of names:

Frank
Sally
Sam
Julie
Joe
Jay
Ralph
John
Sally
Fred
Sue

word count(lines) is 11

I need to print the middle line which is 'Jay' which is the middle (6th) line.

thx.

Don't know which would be faster, but..

# cat names
Frank
Sally
Sam
Julie
Joe
Jay
Ralph
John
Sally
Fred
Sue
# awk '{ lines[NR]=$0; } END { print lines[int(NR/2)+1] }' names
Jay
#

seems to do it.

half=$(( $( wc -l < myFile.txt) / 2 )); echo $half

.... the rest can be done with the original post.

Hey - thanks a million fidodido! You guys are great!

The other guys were correct as well, but it just shows that the ones that are asking for help (me in this case) need to be more specific with their questions.

Thanks again all!