
當我在linux下運行這個命令時,它起作用了:
rm xxx -rf
但在 OSX 中,我必須將參數放在前面,如下所示:
rm -rf xxx
有沒有辦法解決這問題?
答案1
POSIX實際上需要將選項參數放在非選項參數之前:
概要
rm [-fiRr] file...
GNU/Linux 不符合 POSIX,但 OS X 符合。如果設定 POSIXLY_CORRECT,GNU rm 也不允許在選項參數之前放置非選項參數:
$ touch a;grm a -rf
$ touch a;POSIXLY_CORRECT= grm a -rf
grm: cannot remove ‘-rf’: No such file or directory
如果你想用 GNU rm 取代 OS X 的 rm,請執行brew install coreutils
並新增到/usr/local/opt/coreutils/libexec/gnubin
路徑上的其他目錄之前。