Unix/Linux – output the Nth line from a file

by

In order to output the Nth line from a file you can use:

more +N file | head -n 1

Advertisements

4 Responses to “Unix/Linux – output the Nth line from a file”

  1. keramida Says:

    Or my personal favorite:

    head -N file | tail -1

  2. chuckboris Says:

    to output N-th line from end of file:

    tail -N file | head -1

  3. Samuel Lampa (@samuellampa) Says:

    I like to use:
    sed -n ‘[start-line],[end-line]p’

    … so for line 37 in testfile.txt:
    sed -n ‘37,37p’ testfile.txt

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: