Main index

Introducing UNIX and Linux


Advanced shell programming

Overview
Sending and trapping signals
      Signal names
Functions
Aliases
The 'exec' mechanism
The 'eval' mechanism
Sending data across networks
      Sending printable characters
      Splitting files
Makefiles
Safe programming
Setting up a terminal
More on files
Miscellaneous utilities
Summary
Exercises

Exercises

  1. Write a function thisyear to cause the message This year is to be displayed followed by the current year.

    View solution

  2. Write a function changedir to prompt you for a directory name and cd to that directory. Why must you use a function, and not a script?

  3. Write a function called addtopath to request you to type the name of a directory, and if that directory exists and you can read it, to add it to the end of your PATH.

    View solution

  4. Write a script to prompt you for the name of a directory, and the email address of a user, and to mail the contents of that directory to that user.

  5. Define an alias debugsh to have the effect of sh with option -x.

    View solution

  6. Write a script which will, every minute, display the date and time, but when run in the foreground will terminate if it receives ctrl-C 3 times.

  7. Write a script to request you to type in the name of a shell environment variable, and display its value.

    View solution


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck