How should i write a script so that the script will destroy(delete) itself once it completes execution.
Thanks?
How should i write a script so that the script will destroy(delete) itself once it completes execution.
Thanks?
delete itself -- in bash.
Add the following at the end of the script.
unlink $0
Note: Use it with caution.
Would it serve the same purpose in ksh?
Following the theme of "thegeek", there is no reason to destroy an audit trail in a commerical environment. It is normal practice to place temporary scripts under a unique name in /var/tmp or /tmp and delete them after a week.
...especially since $0 isn't always what it's supposed to be. Daemons often call scripts with very odd parameters and paths...
I understand what "thegeek" is saying.
Absolutely. Never hurts to fill in a little detail for the google audience though.
Cool
++++++++++++++