Terminal Command to display a single line from a text file in OS X

I want to display at a specific line, e.g. line 4, from a text file in Terminal (I need this for character counts, using wc). I'm sure this is a simple problem but read -e 1 filename doesn't do it.

What can be used to accomplish this task?


Solution 1:

You can use sed command:

sed -n '4p' YOUR_FILE

Or head/tail combination:

head -n 4 YOUR_FILE | tail -n 1