【linux】文件查找

一.find

通過文件名稱查找

[root@linux ~]# find -name info
./公共/info
./info

通過文件名模糊匹配

[root@linux ~]# find -name *nfo
./公共/info
./info

指定查找范圍

[root@linux ~]# find /etc/gdm -name *.conf
/etc/gdm/custom.conf

通過用戶名稱查找

[root@linux home]# find /home -user jerry
/home/jerry
/home/jerry/.mozilla
/home/jerry/.mozilla/extensions
/home/jerry/.mozilla/plugins
/home/jerry/.bash_logout
/home/jerry/.bash_profile
/home/jerry/.bashrc
/home/jerry/.cache
/home/jerry/.cache/abrt
/home/jerry/.cache/abrt/lastnotification
/home/jerry/.config
/home/jerry/.config/abrt
/home/jerry/.viminfo
/home/jerry/.bash_history
/home/jerry/jerryinfo
/home/info

指定文件大小

[root@linux home]# find /usr/local -size +100M
/usr/local/GoLand-2022.1/lib/app.jar
/usr/local/GoLand-2022.1/plugins/DatabaseTools/lib/database-plugin.jar
/usr/local/GoLand-2022.1/jbr/lib/libcef.so
二.locate

利用系統(tǒng)自動(dòng)生成的一個(gè)數(shù)據(jù)庫去進(jìn)行查找,數(shù)據(jù)庫每天自動(dòng)更新,在查找前可使用updatedb去手動(dòng)更新數(shù)據(jù)庫

[root@linux ~]#  updatedb
[root@linux ~]# locate goland
/home/go/.config/JetBrains/GoLand2022.1/goland.key
/home/go/.config/JetBrains/GoLand2022.1/goland64.vmoptions
三.which/whereis

which查找命令的相關(guān)信息
whereis查找命令所在位置

[root@linux ~]# which ls
alias ls='ls --color=auto'
    /usr/bin/ls
[root@linux ~]# which cd
/usr/bin/cd
[root@linux ~]# whereis which
which: /usr/bin/which /usr/share/man/man1/which.1.gz
四.grep內(nèi)容過濾

-n顯示行號

[root@linux ~]# grep -n one littleprince 
14:But they answered: "Frighten? Why should any one be frightened by a hat?"
21:So then I chose another profession, and learned to pilot airplanes. I have flown a little over all parts of the world; and it is true that geography has been very useful to me. At a glance I can distinguish China from Arizona. If one gets lost in the night, such knowledge is valuable.
25:Whenever I met one of them who seemed to me at all clear-sighted, I tried the experiment of showing him my Drawing Number One, which I have always kept. I would try to find out, so, if this was a person of true understanding. But, whoever it was, he, or she, would always say:

使用管道符|

[root@linux ~]# ls -l | grep .cfg
-rw-------. 1 root root 1850 4月  12 16:31 anaconda-ks.cfg
-rw-r--r--. 1 root root 1898 4月  12 16:32 initial-setup-ks.cfg
五.wc

word count,對文件進(jìn)行計(jì)數(shù)統(tǒng)計(jì),分別是行數(shù) 單詞數(shù) 總字節(jié) 文件名

[root@linux ~]# wc info
  51  318 1956 info
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • which 查看可執(zhí)行文件的位置 命令格式:which 可執(zhí)行文件名稱 命令功能:which指令會在PATH變量指...
    upupSue閱讀 793評論 0 1
  • 對于文件查找,我們最好用的還是屬于find命令了,在說find命令之前,先把另外幾個(gè)查找命令介紹一下。 目錄 0x...
    無心_44d4閱讀 218評論 0 0
  • 在linux下搜索文件只需要幾行簡單的命令就搞定了,不過不同的指令其功能也是不一樣的,使用的時(shí)候要靈活選擇。 wh...
    AwesomeAshe閱讀 382評論 0 2
  • find 功能最強(qiáng)的查找文件命令 -size 按文件大小查找,第一個(gè)參數(shù)為查詢目錄可以不寫查詢目錄,默認(rèn)從當(dāng)前所在...
    Manchangdx閱讀 494評論 0 0
  • 查找文件 一般查找find 最常用的方式find PATH -name FILENAME.例如查找當(dāng)前用戶目錄下的...
    一個(gè)菜鳥JAVA閱讀 254評論 0 3

友情鏈接更多精彩內(nèi)容