home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

15.6 Exercises

See Appendix A, Exercise Answers for answers.

  1. Write a program to read a list of filenames, breaking each name into its head and tail components. (Everything up to the last backslash is the head, and everything after the last slash is the tail. If there's no backslash, everything is in the tail.) Try this exercise with things like \fred , barney , and fred\barney . Do the results make sense?

  2. Write a program to read in a list of numbers on separate lines, and then sort them numerically, printing out the resulting list in a right-justified column. (Hint: the format to print a right-justified column is something like "%20g" .)

  3. Create a file that consists of sentences, one per line. Write a program that makes the first character of each sentence uppercase, and the rest of the sentence lowercase. (Does the program work even when the first character is not a letter? How would you alter the program if the sentences were not already one per line?)