Rick's Tech Talk

All Tech Talk, Most of the Time

Printing Line N

If you're in front of UNIX system, you should have access to sed, the UNIX "stream editor", which has a lot of utility to it. Here's a little idiom that comes in handy every now and then.

% sed -n '16p' file.txt
Not bad for 1/2 hour worth of work!

The string '16p' says "print line 16". So to print any particular line out of a file, use sed -n 'Np' file.txt, where N is the line that you want. And if you want a range of lines, use 'M,Np', where M and N are the starting and ending line numbers in question.

% sed -n '16,18p' 20090308.txt
Not bad for 1/2 hour worth of work!

 Directory of C:\Documents and Settings\Rick\My Documents\Notes
Tags: