If you use a system to make temporary files ( 21.3 ) , your .logout file can clean up the temporary files. The exact cleanup command you'll use depends on how you create the files, of course. The overall setup looks something like this in .logout :
~ |
(set nonomatch; cd ~/temp && rm -f *) & |
---|
The parentheses run the commands in a
subshell (
13.7
)
so the
cd
command won't change the current shell's working directory.
The C shell needs a
set
nonomatch
(
15.4
)
command so the shell will be quiet if there aren't any
temp
files to clean up; omit that command in Bourne-type shells. The
&&
(
44.9
)
means that
rm
won't run unless the
cd
succeeds. Using
cd ~/temp
first, instead of just
rm ~/temp/*
, helps to keep
rm
's command-line arguments from
getting too long (
15.6
)
if there are lots of temporary files to remove.
If you could be logged in more than once, be careful not to remove
temp
files that other login sessions might still be using. One way to do this is with the
find
(
17.2
)
command - only remove files that haven't been modified in the last day:
xargs |
find ~/temp -type f -mtime +1 | xargs rm -f & |
---|
-