什麼是命令原色?

什麼是命令原色?

我從跑步中了解到初選的概念man find

.
.
.
PRIMARIES
     All primaries which take a numeric argument allow the number to be preceded by a plus sign (``+'') or a minus sign (``-'').  A preceding plus sign means ``more than n'', a pre-
     ceding minus sign means ``less than n'' and neither means ``exactly n''.
.
.
     -depth n
             True if the depth of the file relative to the starting point of the traversal is n.

搜尋中POSIX 文檔「初選」沒有結果。

經過一些探索,初級似乎與開關和標誌不同,因為它們出現在開關、標誌和主要參數之後:

$ find -depth 1 .
find: illegal option -- e
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
$ find . -depth 1
./.DS_Store
./.vagrant
./foo
./some

我在想:

  • 什麼是初選?
  • 我可以閱讀有關它們的任何文件嗎?
  • 它們與開關或標誌有何不同?

答案1

它們是 的語言的條件/動作,find用法行中提到的「表達式」主要包括: -name-type、等。 該術語用於將它們與僅組合原色的運算子分開:、、和括號。-print-exec!-a-o

我不記得在除 之外的其他上下文中見過該術語find。它用在POSIX 規範find並在FreeBSD 手冊頁。 GNU 在這方面也很突出,GNU find 的文檔(例如手冊頁)不使用該術語,而是將初選分為測試關於文件的屬性,行動做某事,並且選項影響其find自身的工作方式。這種劃分似乎很有幫助,但有點不準確,因為所有初選都會返回真值,甚至包括操作。

相關內容