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

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 852 | 回復(fù): 0
打印 上一主題 下一主題

exec xargs [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-11-06 13:23 |只看該作者 |倒序?yàn)g覽
The problem is not one of recursion limit, but one of (in)efficiency.
It is much more efficient to use find | xargs than find -exec {} \;
"find ... -exec command {} \;" runs the command once for each name.
If find identifies 10000 files, using -exec grep ... as an example,
find would fork off a child copy of itself, the copy would become a
grep working on a single file.  Meanwhile the original parent find
would sleep waiting for its child (grep) to finish before searching
for the next file that meets the find criteria.  That means 10000
executions of grep and pauses of find.
"xargs command" reads names on its standard input, and feeds them in
bunches to command, so that command is run fewer times (only once, in
most cases).  So, if we use find | xargs grep ..., the find is able to
work "non-stop" filling the pipe with found file names.  xargs
collects groups of about 20 - 50 names and does a single grep for the
collection.  Find doesn't pause and you only do about 200 greps, not
10000. There isn't a forked process for every single file.
The weaknesses of xargs are (1) it can be confused by "funny"
filenames (which is why Gnu has find -print0 |xargs -0, or you can
pipe through sed to add backslashes everywhere), and (2) it can feed
zero arguments to command which might then
just sit there waiting (this is why Gnu xargs has -r which means:
don't run command if stdin is empty).
These days, you can use "find ... -exec command {} +" which groups
arguments together.  However, I found that this did not give
satisfactory grep results when invoked as:
find /usr/include -type f -exec grep NFS_VERSION {} \+ -print (or
without the escaped +)
The following examples show the time difference (and slightly more
useful output of xargs):
$ time find /usr/include -type f -exec grep NFS_VERSION {} \; -print
#define NFS_VERSION     ((rpcvers_t)2)
/usr/include/nfs/nfs.h
#define NFS_VERSION     2
/usr/include/rpcsvc/nfs_prot.h
version NFS_VERSION {
/usr/include/rpcsvc/nfs_prot.x
real    0m9.883s
user    0m3.340s
sys     0m5.900s
$ time find /usr/include -type f|xargs grep NFS_VERSION
/usr/include/nfs/nfs.h:#define  NFS_VERSION     ((rpcvers_t)2)
/usr/include/rpcsvc/nfs_prot.h:#define  NFS_VERSION     2
/usr/include/rpcsvc/nfs_prot.x: version NFS_VERSION {
real    0m0.677s
user    0m0.380s
sys     0m0.310s
               
               
               

本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u1/38576/showart_1384606.html
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP