Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing a line of a file given line number

Tags:

bash

unix

Is it possible, in UNIX, to print a particular line of a file? For example I would like to print line 10 of file example.c. I tried with cat, ls, awk but apparently either these don't have the feature or I'm not able to properly read the man :-).

like image 664
Masiar Avatar asked Nov 28 '22 02:11

Masiar


1 Answers

Using awk:

awk 'NR==10' file

Using sed:

sed '10!d' file
like image 81
Guru Avatar answered Dec 06 '22 09:12

Guru