- Write a program to copy one named file into another named file. The two file
names are given as the first two arguments to the program.
Copy the file a block (512 bytes) at a time.
Check: that the program has two arguments
or print "Program need two arguments"
that the first name file is readable
or print "Cannot open file .... for reading"
that the second file is writable
or print "Cannot open file .... for writing"
(unit8:fileI/O:cp)
-
Write a program last that prints the last n lines of its text
input. By default n should be 5, but your program should allow an optional
argument so that
last -n
prints out the last n lines, where n is any integer. Your program should make the best use of available storage. Input of text should be read in from a file specified from the command also. Your program should allow input in any order ie -n before or after filename.
-
Write a program that sorts a list of integers in ascending order. However if
a -r flag is present on the command line your program should sort the list in
descending order. (You may use any sorting routine you wish)
(Example only - not marked by ceilidh)
- Write a program to compare two files and print out the lines where they
differ. Hint: look up appropriate string and file handling library routines.
This should not be a very long program.
(Example only - cannot be marked by ceilidh)