In the script I am creating a temporary file with process id as temp.txt.$$
I want to remove this tomporary file first from the current directory when i'll run the same script next time.
Note: Every time when the script executes then it has unique process id and it'll create a unique temporary file. $$ shows the process id.
If the file is truely a temporary file then delete it when your script finishes....
#!/bin/sh
cleanup()
{
for d in $LAUNDRY_LIST
do
if test -f "$d"
then
rm "$d"
fi
done
}
trap cleanup 0
blah >my.tmp.$$
LAUNDRY_LIST="$LAUNDRY_LIST my.tmp.$$"
dostuff
do more stuff