亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: find命令問題 [打印本頁]

作者: songyc_2015    時(shí)間: 2015-04-20 18:43
標(biāo)題: find命令問題
請(qǐng)教大神一個(gè)問題:

需求:在當(dāng)前目錄下(不查詢databak子目錄),查找符合"*20150408*"的文件

在當(dāng)前目錄下:
$ls -F
20150408/     20150408.tar      databak/

$find ./ \( -name "databak" -prune \) -o -name "*20150408*" -type f -print
./20150408.tar

$find ./ \( -name "databak" -prune \) -o -name "*20150408*" -type f
./20150408.tar
./databak

測(cè)試系統(tǒng):IBM AIX6.1

問題:
1.為什么第2條find少了-print選項(xiàng),結(jié)果會(huì)多出一個(gè)"./databak"?
2.-print是find命令默認(rèn)選項(xiàng)嗎?
作者: songyc_2015    時(shí)間: 2015-04-20 23:56
知道答案了,因?yàn)椋?br />
The  expression  is  made  up of options (which affect overall operation rather than the processing of a specific file, and always return true),
tests (which return a true or false value), and actions (which have side effects and return a true or false value), all separated by  operators.
-and is assumed where the operator is omitted.

If the expression contains no actions other than -prune, -print is performed on all files for which the expression is true.
所以:一下命令是等價(jià)的:
find ./ \( -name "databak" -prune \) -o -name "*20150408*" -type f
find ./ \( \( -name "databak" -a -prune \) -o \( -name '*20150408*' -a -type f \) \) -a -print
find ./ \( -name "databak" -prune -a -print \) -o -name "*20150408*" -type f -a -print

因此結(jié)果多了一個(gè)"./databak"




歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2