系統大全為您提供?前些天在跟大伙討論linux查找文件速度的問題;大家都一致決定find?[path]?-name?"keyword"太慢了,而且太浪費cpu了;有木有一個比較好的idea嗎?當然有了。locate?初入linux道行的,或者是接觸一年半載的人很少經常用他;可能他比find多了兩個字母吧;并且沒有find好記;所以就被初學者遺忘在角落里面;[10:53?@?stm32?]$?locate?-hUsage:?locate?[OPTION]…?[PATTERN]…Search?for?entries?in?a?mlocate?database.-b,?--basename?match?only?the?base?name?of?path?names-c,?--count?only?print?number?of?found?entries-d,?--database?DBPATH?use?DBPATH?instead?of?default?database?(which?isarb/mlocate/mlocate.db)-e,?--existing?only?print?entries?for?currently?existing?files-L,?--follow?follow?trailing?symbolic?links?when?checking?fileexistence?(default)-h,?--help?print?this?help-i,?--ignore-case?ignore?case?distinctions?when?matching?patterns-l,?--limit,?-n?LIMIT?limit?output?(or?counting)?to?LIMIT?entries-m,?--mmap?ignored,?for?backward?compatibility-P,?--nofollow,?-H?don't?follow?trailing?symbolic?links?when?checking?fileexistence-0,?--null?separate?entries?with?NUL?on?output-S,?--statistics?don't?search?for?entries,?print?statistics?about?eachused?database-q,?--quiet?report?no?error?messages?about?reading?databases-r,?--regexp?REGEXP?search?for?basic?regexp?REGEXP?instead?of?patterns--regex?patterns?are?extended?regexps-s,?--stdio?ignored,?for?backward?compatibility-V,?--version?print?version?information-w,?--wholename?match?whole?path?name?(default)Report?bugs?to?mitr@redhat.comlocate命令可以在搜尋數據庫時快速找到檔案,數據庫由updatedb程序來更?新,updatedb是由cron?daemon周期性建立的,locate命令在搜尋數據庫時比由整個由硬盤資料來搜尋資料來得快,但較差勁的是locate所找到的檔案若是最近才建立或?剛更名的,可能會找不到,在內定值中,updatedb每天會跑一次,可以由修改crontab來更新設定值。(etc/crontab)locate指定用在搜尋符合條件的檔案,它會去儲存檔案與目錄名稱的數據庫內,尋找合乎范本樣式條件的檔案或目錄錄,可以使用特殊字元(如?"*"或"?"等)來指定范本樣式,如指定范本為kcpa*ner,?locate會找出所有起始字串為kcpa且結尾為ner的檔案或目錄,如名稱為kcpartner若目錄錄名稱為kcpa_ner則會列出該目錄下包括?子目錄在內的所有檔案。locate指令和find找尋檔案的功能類似,但locate是透過update程序將硬盤中的所有檔案和目錄資料先建立一個索引數據庫,在執行?loacte時直接找該索引,查詢速度會較快,索引數據庫一般是由操作系統管理,但也可以直接下達update強迫系統立即修改索引數據庫。不過第一次在執行update後再使用locate尋找檔案常會失敗,此時就要執行slocate?ˉu該命令(也可執行updatedb指令,其效果相同)來更新slocate數據庫,該命令會在/usr/sbin下產生slocate執行檔,再由?locate到此數據庫尋找所要找的資料。locate:該命令在運行時需要后臺索引的數據庫作為支撐,在?Ubuntu?中這個數據庫文件位于?ar/cache/locate/locatedb.一般來說,這個數據庫文件每天是通過?cron?自動更新的。如果不幸沒有得到更新,那么可以執行?sudo?updatedb?來手動更新。[10:59?@?stm32?]$?sudo?updatedb[10:59?@?stm32?]$?locate?xxxxx[11:00?@?stm32?]$?locate?xxxx/homeenzhenwei/embededproject/platform/s3c24x0/kernelnux-3.0/arch/arm/mach-omap2/sdram-numonyx-m65kxxxxam.h/homeenzhenwei/embededproject/platform/s3c24x0/kernelnux-3.0/drivers/scsi/3w-xxxx.c/homeenzhenwei/embededproject/platform/s3c24x0/kernelnux-3.0/drivers/scsi/3w-xxxx.h/homeenzhenwei/embededproject-code/platform/s3c24x0/kernelnux-3.0/arch/arm/mach-omap2/sdram-numonyx-m65kxxxxam.h/homeenzhenwei/embededproject-code/platform/s3c24x0/kernelnux-3.0/drivers/scsi/3w-xxxx.c/homeenzhenwei/embededproject-code/platform/s3c24x0/kernelnux-3.0/drivers/scsi/3w-xxxx.h/homeenzhenwei/fl2440/kernelnux-3.0/arch/arm/mach-omap2/sdram-numonyx-m65kxxxxam.h/homeenzhenwei/fl2440/kernelnux-3.0/drivers/scsi/3w-xxxx.c/homeenzhenwei/fl2440/kernelnux-3.0/drivers/scsi/3w-xxxx.h/homeenzhenwei/fl2440nux-3.0/arch/arm/mach-omap2/sdram-numonyx-m65kxxxxam.h/homeenzhenwei/fl2440nux-3.0/drivers/scsi/3w-xxxx.c/homeenzhenwei/fl2440nux-3.0/drivers/scsi/3w-xxxx.hb/modules/2.6.32-220.el6.i686/kernel/drivers/scsi/3w-xxxx.ko/optildroot-2011.11/output/toolchainnux-2.6.37/arch/arm/mach-omap2/sdram-numonyx-m65kxxxxam.h/optildroot-2011.11/output/toolchainnux-2.6.37/drivers/scsi/3w-xxxx.c/optildroot-2011.11/output/toolchainnux-2.6.37/drivers/scsi/3w-xxxx.h/usr/foomatic/source/printer/Panasonic-KX-Pxxxx_24-pin.xml/usrc/kernels/2.6.32-220.el6.i686/include/configk/dev/3wxx/usrc/kernels/2.6.32-220.el6.i686/include/configk/dev/3wxx/raid.h[11:00?@?stm32?]$也許這個可以給你帶來很多方便;???以上就是系統大全給大家介紹的如何使的方法都有一定的了解了吧,好了,如果大家還想了解更多的資訊,那就趕緊點擊系統大全官網吧。??本文來自系統大全http:///如需轉載請注明!推薦:win7純凈版