Geo*_*ndo 2 windows bash batch-file self-destruction
我有一个卸载脚本,可以清理与应用程序一起使用的附加工具.该脚本的版本在Windows和Linux上运行.
我希望能够删除卸载脚本文件以及脚本运行的目录(在Windows批处理文件的情况下以及Linux bash文件的情况下).现在除了脚本和运行它的目录之外的所有内容在运行后仍然存在.
如何删除脚本和脚本的目录?
谢谢
mic*_*slm 10
在Bash,你可以做到
#!/bin/bash
# do your uninstallation here
# ...
# and now remove the script
rm $0
# and the entire directory
rmdir `dirname $0`
Run Code Online (Sandbox Code Playgroud)