Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(C programming) please try to avoid using (scanf and printf) 1. end wite a uit arguments (flename andn) and wites to stdout the last n
(C programming) please try to avoid using (scanf and printf)
1. end wite a uit arguments (flename andn) and wites to stdout the last n lines of the file filename. If the filename does not exist, the program should display an error. . If n is not greater than 0 and less than 10, the program should generate an error . If n is not specified, the program should write only the last 5 lines Your program should read the file 10 characters at a time. 2. capture This solution to this problem will require using some system calls that will be discussed in week 3. This program should accept the name of a file that includes a list of commands (one per line) to execute. Each line of the file should be executed by a subprocess and the output written to the file capture.txt For example, given the command file: /bin/ls -1 /bin/cat apple banana The output saved to capture.txt might be: ----+ 1 schubert them 51 Jan 18 12:07 apple +1 schubert them 27 Jan 18 12:09 banana + 1 schubert them 13179 Jan 18 12:15 cantaloupe first line of file apple second line of file apple banana first and only line 41 217 cantaloupe unlink open close dup read write lseek remove a file open a file for reading/writing close a previously open file duplicate an existing file descriptor extract info from a file put info into a file move to specified location in a file fork execl wait exit dup, dup2 duplicate an existing file descriptor kill create a new almost-copy of the current program replace program being executed with a new one wait for child process to complete terminate self Send a signal to a process To send a signal To handle a signal signal (sig, handler) kill (pid, sig)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started