Show a given line number from file

sed 'NUMq;d' file

Where NUM is the number of the line you want to print; so, for example sed ’10q;d’ file to print the 10th line of file.


NUMq will quit immediately when the line number is NUM.

d will delete the line instead of printing it; this is inhibited on the last line because the q causes the rest of the script to be skipped when quitting.

If you have NUM in a variable, you will want to use double quotes instead of single:

sed "${NUM}q;d" file