[prev] [index] [next]

Exercises: shell scripts (2)

  1. Write a shell script called isint that checks whether its argument looks like an integer value

    Include suitable error checking and reporting (e.g. missing argument)

  2. Write a shell script called istext that checks whether its argument is a text file

    Include suitable error checking and reporting (e.g. missing argument, not a file)

  3. Write a shell script called iota to generate a sequence of integers one per line, with usage:

    iota 
      # gives 1 2 3 4 5 6 7 8 9 10 ...
    iota lo
      # e.g. iota 4 gives 4 5 6 7 8 9 10 ...
    iota lo hi
      # e.g. iota 4 8 gives 4 5 6 7 8
    iota lo hi step
      # e.g. iota 2 12 3 gives 2 5 8 11
    

    Include appropriate error checking.

  4. Write a shell script called prod to compute the product of a sequence of numbers given one per line on standard input
    • consider what kind of errors might occur
    • how should each be handled?
  5. Make a link from prod called sum and modify the script so that it behaves differently depending on how it is invoked.