利用Linux Find命令快速查找文件方法
在茫茫的linux系統(tǒng)種我們?nèi)绾慰焖俚牟檎椅募???duì)于系統(tǒng)文件基本上是有固定的位置的,但是有些軟件安裝文件是有自定義位置的,不熟悉的運(yùn)維人員交接后我們需要重新適應(yīng)各個(gè)運(yùn)維人員的安裝習(xí)慣。這里我們用的較多的還是linux find命令進(jìn)行快速查找定位。
一、find 命令基本使用方法
find 命令格式如下:
find PATH EXPRESSIONS... ACTIONS...
比如,我想查找 /etc/passwd 這個(gè)文件:
find /etc -name passwd -print
查找結(jié)果如下:
# find /etc -name passwd -print /etc/pam.d/passwd /etc/cron.daily/passwd /etc/passwd
其中 -print 命令是可選的,可以不用一起打,同樣會(huì)輸出結(jié)果。
二、find 命令進(jìn)階用法
如果我不知道目錄,那么可以直接在根目錄下面搜索:
# find / -name passwd -print /etc/pam.d/passwd /etc/cron.daily/passwd /etc/passwd /usr/bin/passwd /usr/share/doc/passwd /usr/share/lintian/overrides/passwd /usr/share/bash-completion/completions/passwd #
此外,-iname 可以用來代替 -name,表示大小寫敏感查找。
此外也可以根據(jù)其他參數(shù)進(jìn)行查找,比如根據(jù)大?。?/p>
# dd if=/dev/zero of=/root/bigfile bs=1048576 count=512 512+0 records in 512+0 records out 536870912 bytes (537 MB, 512 MiB) copied, 0.490124 s, 1.1 GB/s # find / -size +100M -print /proc/kcore find: ‘/proc/2381/task/2381/fd/6': No such file or directory find: ‘/proc/2381/task/2381/fdinfo/6': No such file or directory find: ‘/proc/2381/fd/5': No such file or directory find: ‘/proc/2381/fdinfo/5': No such file or directory /root/bigfile
或者根據(jù)時(shí)間:
# mkdir /backup # touch -t 201008201111 /backup/some_old_backup.tar.gz # touch /backup/current_backup.tar.gz # ll /backup total 8 drwxr-xr-x 2 root root 4096 May 24 18:42 . drwxr-xr-x 19 root root 4096 May 24 18:40 .. -rw-r--r-- 1 root root 0 May 24 18:42 current_backup.tar.gz -rw-r--r-- 1 root root 0 Aug 20 2010 some_old_backup.tar.gz # find /backup -mtime +30 -print /backup/some_old_backup.tar.gz
到此這篇關(guān)于利用Linux Find命令快速查找文件方法的文章就介紹到這了,更多相關(guān)Linux Find命令查找文件位置內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
shell腳本學(xué)習(xí)指南[二](Arnold Robbins & Nelson H.F. Beebe著)
這篇文章主要介紹了shell腳本學(xué)習(xí)指南[二](Arnold Robbins & Nelson H.F. Beebe著),需要的朋友可以參考下2014-02-02linux shell腳本對(duì)未定義變量的判斷以及if的用法詳解
今天小編就為大家分享一篇linux shell腳本對(duì)未定義變量的判斷以及if的用法詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-07-07bash腳本編程學(xué)習(xí)之算術(shù)運(yùn)算與文件查找
算數(shù)運(yùn)算在每個(gè)編程語言里面是最基本的功能,在bash里面也是。下面這篇文章就給大家詳細(xì)介紹了腳本編程bash中的算術(shù)運(yùn)算與文件查找,文中還給出了多道練習(xí)題和答案,有需要的朋友們可以參考借鑒,下面來一起看看吧。2016-12-12Linux 中shell腳本設(shè)置開頭固定格式的實(shí)現(xiàn)方法
這篇文章主要介紹了Linux 中shell腳本設(shè)置開頭固定格式的實(shí)現(xiàn)方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-10linux啟動(dòng)級(jí)別的含義(init 0-6)
這篇文章主要介紹了linux啟動(dòng)級(jí)別的含義(init 0-6),需要的朋友可以參考下2014-02-02