Shell: can i use the command line style `rm tmp / -fr` in mac

Say I want to remove tmp / dir in a shell.

In linux (e.g. ubuntu) I can rm tmp/ -fror rm -fr tmp/. But on mac, I can only rm -fr tmp/.

Is there a way to customize the mac shell (bash / zsh / ...), so I can use a command line style like linux rm tmp/ -fr:?

+3
source share
3 answers

The presence of options after the operands, as in rm tmp/ -fr, is non-standard. IEEE Std 1003.1-2001 is provided in Section 12.2 Utility Syntax Guide :

Guide 9: All parameters must precede operands on the command line.

GNU ( Linux) . , . MacOS X , BSD, GNU. , GNU, BSD, Solaris UNIX , - GNU. UNIX. . GNU , .

, GNU coreutils MacOS X, (IEEE Std 1003.1, POSIX.2 ..).

+4

, . OS X BSD ( NeXTSTEP), BSD. BSD Linux, . Linux- , GNU coreutils. Homebrew () MacPorts. , , GNU coreutils BSD toolchain - ..

+3

, . , rm ( rm), , . , , .

  • rm -fr tmp/: will delete the directory tmp/with the parameters -rand -f, therefore, recursive (mandatory here) and forced.
  • rm tmp/ -fr: Will (attempt to) delete the directory tmp/and / or file / directory named is -fr, but it will lead to error: rm: tmp/ directory.

Note: the only way to delete a file with a name -rfis to use rm -- -rf.

0
source

All Articles