1.

Solve : HOW CAN I PRINT FROM LIN 10 TO 34 IN ANY FILE USING HEAD AND TAIL COMMAND?

Answer»

HOW CAN I PRINT LINE 10 TO 34 IN ANY FILE USING HEAD AND TAIL COMMAND IN UNIX SYSTEM?cat the file, via a pipe to head to get the first 34 lines of the file, then another pipe to tail to get the last 24 lines of that. (34-10=24). If you meant print to a line printer, redirect the output to the printer device.

USE the appropriate switch for head and tail to get lines, not bytes.

PS Typing all in capitals is very bad manners. It is the same as shouting. Please don't do it any more.

PPS man PAGES are on most linux systems.





Quote from: kuldeep on May 28, 2007, 08:14:36 AM

HOW CAN I PRINT LINE 10 TO 34 IN ANY FILE USING HEAD AND TAIL COMMAND IN UNIX SYSTEM?

no need to SHOUT!

Code: [Select]tail +10 filename | head -24 | lpdoing homework right? if not, there's no reason you can't use sed
Code: [Select]sed -n '10,34p' file
Good one, Ghostdog

http://gnuwin32.sourceforge.net/packages/sed.htm

http://www.student.northpark.edu/pemente/sed/sed1line.txt


Discussion

No Comment Found