Linux print text at a specified line

 

To print a text at specific line number we can use sed or awk command.

If we want to print line number 10 form input.txt file use following command:

$ sed -n '10p' input.txt
$ awk 'NR==10' input.txt

Both command mentiond above will print content at line number 10 in input.txt file.

-Sany

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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