终端:如何从硬盘驱动器上永久删除文件

Terminal: How to permanently remove a file off hard drive

所以我一直在创建一个本质上类似于 HelperBot 的程序,我想添加一个功能,它可以从硬盘驱动器中完全删除文件,而不是将它们移动到回收站并清空回收站。我在 AppleScript 中编码,这是我的代码: “执行 shell 脚本“rm /user/Downloads/file.app/*”” 这是错误的还是有其他方法可以做到这一点?

系统事件 将永久删除文件而不通过回收站:

tell application "System Events" to delete the file "/path/to/file.ext"

或者,删除文件夹:

tell application "System Events" to delete the folder "/path/to/folder"