Question: IN C , Write a utility program that takes one or two arguments (filename and -n) and writes to STDOUT the first n lines of
IN C,
Write a utility program that takes one or two arguments (filename and -n) and writes to STDOUT the first n lines of the file filename. If filename is not specified, the program should read from STDIN If -n is not specified, the program should write only the first line. Your program should read the file 10 characters at a time.


1 abc 2 def ghi 3 jkl mno 4 par stu vwx 5 yz -/Documents/test> ./header abc abc def ghi jkl mno par stu vwx yz ABC DEF GHI JKL MNO POR STU VWX YZ -/Documents/test> ./header abc - 10 abc def ghi jklmno par stu vwx yz ABC | DEF GHI JKL MNO POR STU VWX 6 ABC 7 DEF GHI 8 JKL MNO 9 PQR STU VWX 10 YZ 11 12 123 456 6790 13 For initial testing, I set the default number of lines to print to 10. In the final version, the number should be 1. YZ - Documents/test> --/Documents/test> ./header abc - 1 abc - Documents/test> ./header abc -2 abc def ghi - Documents/test> ./header abc - 3 abc def ghi jkl mno - Documents/test> ./header abc - 5 abc def ghi jkl mno par stu vwx yz -/Documents/test> ./header abc -11 abc def ghi jkl mno par stu vwx yz ABC DEF GHI JKL MNO POR STU VWX YZ - Documents/test>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
