One of the drawbacks of using the Bourne shell is that unlike other shells, it does not have a .logout file. This file holds commands that you want executed just before your session is terminated when you issue an exit command.
But by using the trap command (more on trap and signals later in the book), the Bourne shell can have its own .logout file. Here’s how to do it. Edit your .profile file and put the following command on the last line of your .profile file, then save and exit the file.
trap "$HOME/.logout" 0
Now create a .logout file and enter any commands you want executed. You can put in anything you like.
$ pg .logout rm -f $HOME/*.log rm -f $HOME/*.tmp echo "Bye...bye $LOGNAME"
The .logout file is called ...