为什么 -r 递归标志在某些情况下大写而在其他情况下较低?

Lee*_*lla 8 linux command-line

一些命令使用小写字母r作为其递归标志,而其他命令使用大写字母R

cp -r foo/ bar/

chmod -R 777 foobar/
Run Code Online (Sandbox Code Playgroud)

是否有一个原因?

Den*_*nis 8

cp 实际上两者都接受。

来自cp --help

  -R, -r, --recursive          copy directories recursively
Run Code Online (Sandbox Code Playgroud)

为了一致性,大多数 shell 命令-R用作递归标志,可能是因为它们模仿ls.

来自ls --help

  -r, --reverse              reverse order while sorting
  -R, --recursive            list subdirectories recursively
Run Code Online (Sandbox Code Playgroud)

  • 此外,`chmod -r` 已经被用来表示递归以外的东西! (2认同)