self-deleting shell script March 5, 2023 by Tarik rm -- "$0" Ought to do the trick. $0 is a magic variable for the full path of the executed script.