O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.4. Creating a .logout file

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required