Reputation: 125
I have a bash script which does some operations and at the end I would like the script to delete the folder in which it is contained. So I put at the end of the script the following commands
olddir=`pwd`
cd ..
rm -rf "$olddir"
The content of the folder is deleted, but the folder not and I get the following error
rm: cannot remove `folder': Directory not empty
The script is called by a pbs script which is also contained in the same folder. What is the problem?
Upvotes: 2
Views: 198
Reputation: 7203
If you wish to clean up a directory that the job is going to use, the best thing to do would probably be to create a specific directory at the beginning of the job instead of simply backing up and deleting the current directory as you are currently doing.
I think you'd be better off doing something like:
Upvotes: 0