一、find命令簡(jiǎn)介
Linux下find命令在目錄結(jié)構(gòu)中搜索文件,并執(zhí)行指定的操作。Linux下find命令提供了相當(dāng)多的查找條件,功能很強(qiáng)大。由于find具有強(qiáng)大的功能,所以它的選項(xiàng)也很多,其中大部分選項(xiàng)都值得我們花時(shí)間來(lái)了解一下。即使系統(tǒng)中含有網(wǎng)絡(luò)文件系統(tǒng)( NFS),find命令在該文件系統(tǒng)中同樣有效,只你具有相應(yīng)的權(quán)限。 在運(yùn)行一個(gè)非常消耗資源的find命令時(shí),很多人都傾向于把它放在后臺(tái)執(zhí)行,因?yàn)楸闅v一個(gè)大的文件系統(tǒng)可能會(huì)花費(fèi)很長(zhǎng)的時(shí)間(這里是指30G字節(jié)以上的文件系統(tǒng))。
1.命令格式:
find pathname -options [-PRint -exec -ok ...]
2.命令功能:
用于在文件樹種查找文件,并作出相應(yīng)的處理
3.命令參數(shù):
pathname: find命令所查找的目錄路徑。例如用.來(lái)表示當(dāng)前目錄,用/來(lái)表示系統(tǒng)根目錄。 -print: find命令將匹配的文件輸出到標(biāo)準(zhǔn)輸出。 -exec: find命令對(duì)匹配的文件執(zhí)行該參數(shù)所給出的shell命令。相應(yīng)命令的形式為'command' { } /;,注意{ }和/;之間的空格。 -ok: 和-exec的作用相同,只不過(guò)以一種更為安全的模式來(lái)執(zhí)行該參數(shù)所給出的shell命令,在執(zhí)行每一個(gè)命令之前,都會(huì)給出提示,讓用戶來(lái)確定是否執(zhí)行。
4.命令選項(xiàng):
-name 按照文件名查找文件。-perm 按照文件權(quán)限來(lái)查找文件。-prune 使用這一選項(xiàng)可以使find命令不在當(dāng)前指定的目錄中查找,如果同時(shí)使用-depth選項(xiàng),那么-prune將被find命令忽略。-user 按照文件屬主來(lái)查找文件。-group 按照文件所屬的組來(lái)查找文件。-mtime -n +n 按照文件的更改時(shí)間來(lái)查找文件, - n表示文件更改時(shí)間距現(xiàn)在n天以內(nèi),+ n表示文件更改時(shí)間距現(xiàn)在n天以前。find命令還有-atime和-ctime 選項(xiàng),但它們都和-m time選項(xiàng)。-nogroup 查找無(wú)有效所屬組的文件,即該文件所屬的組在/etc/groups中不存在。-nouser 查找無(wú)有效屬主的文件,即該文件的屬主在/etc/passwd中不存在。-newer file1 ! file2 查找更改時(shí)間比文件file1新但比文件file2舊的文件。-type 查找某一類型的文件,諸如:b - 塊設(shè)備文件。d - 目錄。c - 字符設(shè)備文件。p - 管道文件。l - 符號(hào)鏈接文件。f - 普通文件。-size n:[c] 查找文件長(zhǎng)度為n塊的文件,帶有c時(shí)表示文件長(zhǎng)度以字節(jié)計(jì)。-depth:在查找文件時(shí),首先查找當(dāng)前目錄中的文件,然后再在其子目錄中查找。-fstype:查找位于某一類型文件系統(tǒng)中的文件,這些文件系統(tǒng)類型通常可以在配置文件/etc/fstab中找到,該配置文件中包含了本系統(tǒng)中有關(guān)文件系統(tǒng)的信息。-mount:在查找文件時(shí)不跨越文件系統(tǒng)mount點(diǎn)。-follow:如果find命令遇到符號(hào)鏈接文件,就跟蹤至鏈接所指向的文件。-cpio:對(duì)匹配的文件使用cpio命令,將這些文件備份到磁帶設(shè)備中。
另外,下面三個(gè)的區(qū)別:
-amin n 查找系統(tǒng)中最后N分鐘訪問的文件-atime n 查找系統(tǒng)中最后n*24小時(shí)訪問的文件-cmin n 查找系統(tǒng)中最后N分鐘被改變文件狀態(tài)的文件-ctime n 查找系統(tǒng)中最后n*24小時(shí)被改變文件狀態(tài)的文件-mmin n 查找系統(tǒng)中最后N分鐘被改變文件數(shù)據(jù)的文件-mtime n 查找系統(tǒng)中最后n*24小時(shí)被改變文件數(shù)據(jù)的文件
園子里另一個(gè)博客,也寫得非常不錯(cuò):
Linux find 用法示例 - wanqi - 博客園http://www.CUOXin.com/wanqieddy/archive/2011/06/09/2076785.html Linux find 用法示例
二、find命令的用法示例以下內(nèi)容轉(zhuǎn)載自(竹子-博客(.NET/java/Linux/架構(gòu)/管理/敏捷))原文地址 : http://www.CUOXin.com/peida/archive/2012/11/16/2773289.html
find一些常用參數(shù)的一些常用實(shí)例和一些具體用法和注意事項(xiàng)。
1.使用name選項(xiàng):
文件名選項(xiàng)是find命令最常用的選項(xiàng),要么單獨(dú)使用該選項(xiàng),要么和其他選項(xiàng)一起使用。可以使用某種文件名模式來(lái)匹配文件,記住要用引號(hào)將文件名模式引起來(lái)。不管當(dāng)前路徑是什么,如果想要在自己的根目錄$HOME中查找文件名符合*.log的文件,使用~作為'pathname'參數(shù),波浪號(hào)~代表了你的$HOME目錄。
find~-name"*.log"-print
想要在當(dāng)前目錄及子目錄中查找所有的‘*.log‘文件,可以用:
find.-name"*.log"-print
想要的當(dāng)前目錄及子目錄中查找文件名以一個(gè)大寫字母開頭的文件,可以用:
find.-name"[A-Z]*"-print
想要在/etc目錄中查找文件名以host開頭的文件,可以用:
find/etc-name"host*"-print
想要查找$HOME目錄中的文件,可以用:
find~-name"*"-print或find.-print
要想讓系統(tǒng)高負(fù)荷運(yùn)行,就從根目錄開始查找所有的文件。
find/-name"*"-print
如果想在當(dāng)前目錄查找文件名以一個(gè)個(gè)小寫字母開頭,最后是4到9加上.log結(jié)束的文件:
命令:
find.-name"[a-z]*[4-9].log"-print
輸出:
[root@localhosttest]#ll
總計(jì)316
-rw-r--r--1rootroot30210811-1306:03log2012.log
-rw-r--r--1rootroot6111-1306:03log2013.log
-rw-r--r--1rootroot011-1306:03log2014.log
-rw-r--r--1rootroot011-1306:06log2015.log
drwxr-xr-x6rootroot409610-2701:58scf
drwxrwxr-x2rootroot409611-1306:08test3
drwxrwxr-x2rootroot409611-1305:50test4
[root@localhosttest]#find.-name"[a-z]*[4-9].log"-print
./log2014.log
./log2015.log
./test4/log2014.log
[root@localhosttest]#
2.用perm選項(xiàng):
按照文件權(quán)限模式用-perm選項(xiàng),按文件權(quán)限模式來(lái)查找文件的話。最好使用八進(jìn)制的權(quán)限表示法。
如在當(dāng)前目錄下查找文件權(quán)限位為755的文件,即文件屬主可以讀、寫、執(zhí)行,其他用戶可以讀、執(zhí)行的文件,可以用:
[root@localhosttest]#find.-perm755-print
.
./scf
./scf/lib
./scf/service
./scf/service/deploy
./scf/service/deploy/product
./scf/service/deploy/info
./scf/doc
./scf/bin
[root@localhosttest]#
還有一種表達(dá)方法:在八進(jìn)制數(shù)字前面要加一個(gè)橫杠-,表示都匹配,如-007就相當(dāng)于777,-005相當(dāng)于555,
命令:
find.-perm-005
輸出:
[root@localhosttest]#ll
總計(jì)316
-rw-r--r--1rootroot30210811-1306:03log2012.log
-rw-r--r--1rootroot6111-1306:03log2013.log
-rw-r--r--1rootroot011-1306:03log2014.log
-rw-r--r--1rootroot011-1306:06log2015.log
drwxr-xr-x6rootroot409610-2701:58scf
drwxrwxr-x2rootroot409611-1306:08test3
drwxrwxr-x2rootroot409611-1305:50test4
[root@localhosttest]#find.-perm-005
.
./test4
./scf
./scf/lib
./scf/service
./scf/service/deploy
./scf/service/deploy/product
./scf/service/deploy/info
./scf/doc
./scf/bin
./test3
[root@localhosttest]#
3.忽略某個(gè)目錄:
如果在查找文件時(shí)希望忽略某個(gè)目錄,因?yàn)槟阒滥莻€(gè)目錄中沒有你所要查找的文件,那么可以使用-prune選項(xiàng)來(lái)指出需要忽略的目錄。在使用-prune選項(xiàng)時(shí)要當(dāng)心,因?yàn)槿绻阃瑫r(shí)使用了-depth選項(xiàng),那么-prune選項(xiàng)就會(huì)被find命令忽略。如果希望在test目錄下查找文件,但不希望在test/test3目錄下查找,可以用:
命令:
findtest-path"test/test3"-prune-o-print
輸出:
[root@localhostsoft]#findtest-path"test/test3"-prune-o-print
test
test/log2014.log
test/log2015.log
test/test4
test/test4/log2014.log
test/test4/log2013.log
test/test4/log2012.log
test/scf
test/scf/lib
test/scf/service
test/scf/service/deploy
test/scf/service/deploy/product
test/scf/service/deploy/info
test/scf/doc
test/scf/bin
test/log2013.log
test/log2012.log
[root@localhostsoft]#
4.使用find查找文件的時(shí)候怎么避開某個(gè)文件目錄:
實(shí)例1:在test目錄下查找不在test4子目錄之內(nèi)的所有文件
命令:
findtest-path"test/test4"-prune-o-print
輸出:
[root@localhostsoft]#findtest
test
test/log2014.log
test/log2015.log
test/test4
test/test4/log2014.log
test/test4/log2013.log
test/test4/log2012.log
test/scf
test/scf/lib
test/scf/service
test/scf/service/deploy
test/scf/service/deploy/product
test/scf/service/deploy/info
test/scf/doc
test/scf/bin
test/log2013.log
test/log2012.log
test/test3
[root@localhostsoft]#findtest-path"test/test4"-prune-o-print
test
test/log2014.log
test/log2015.log
test/scf
test/scf/lib
test/scf/service
test/scf/service/deploy
test/scf/service/deploy/product
test/scf/service/deploy/info
test/scf/doc
test/scf/bin
test/log2013.log
test/log2012.log
test/test3
[root@localhostsoft]#
說(shuō)明:
find[-path..][expression]
在路徑列表的后面的是表達(dá)式
-path"test"-prune-o-print是-path"test"-a-prune-o-print的簡(jiǎn)寫表達(dá)式按順序求值,-a和-o都是短路求值,與shell的&&和||類似如果
-path"test"為真,則求值-prune,-prune返回真,與邏輯表達(dá)式為真;否則不求值-prune,與邏輯表達(dá)式為假。如果-path"test"-a-prune為假,則求值-print,-print返回真,或邏輯表達(dá)式為真;否則不求值-print,或邏輯表達(dá)式為真。
這個(gè)表達(dá)式組合特例可以用偽碼寫為:
if-path"test"then
-prune
else
實(shí)例2:避開多個(gè)文件夾:
命令:
findtest/(-pathtest/test4-o-pathtest/test3/)-prune-o-print
輸出:
[root@localhostsoft]#findtest/(-pathtest/test4-o-pathtest/test3/)-prune-o-print
test
test/log2014.log
test/log2015.log
test/scf
test/scf/lib
test/scf/service
test/scf/service/deploy
test/scf/service/deploy/product
test/scf/service/deploy/info
test/scf/doc
test/scf/bin
test/log2013.log
test/log2012.log
[root@localhostsoft]#
說(shuō)明:
圓括號(hào)表示表達(dá)式的結(jié)合。/表示引用,即指示shell不對(duì)后面的字符作特殊解釋,而留給find命令去解釋其意義。
實(shí)例3:查找某一確定文件,-name等選項(xiàng)加在-o之后
命令:
findtest/(-pathtest/test4-o-pathtest/test3/)-prune-o-name"*.log"-print
輸出:
[root@localhostsoft]#findtest/(-pathtest/test4-o-pathtest/test3/)-prune-o-name"*.log"-print
test/log2014.log
test/log2015.log
test/log2013.log
test/log2012.log
[root@localhostsoft]#
5.使用user和nouser選項(xiàng):
按文件屬主查找文件:
實(shí)例1:在$HOME目錄中查找文件屬主為peida的文件
命令:
find~-userpeida-print
實(shí)例2:在/etc目錄下查找文件屬主為peida的文件:
命令:
find/etc-userpeida-print
說(shuō)明:
實(shí)例3:為了查找屬主帳戶已經(jīng)被刪除的文件,可以使用-nouser選項(xiàng)。在/home目錄下查找所有的這類文件
命令:
find/home-nouser-print
說(shuō)明:
這樣就能夠找到那些屬主在/etc/passwd文件中沒有有效帳戶的文件。在使用-nouser選項(xiàng)時(shí),不必給出用戶名;find命令能夠?yàn)槟阃瓿上鄳?yīng)的工作。
6.使用group和nogroup選項(xiàng):
就像user和nouser選項(xiàng)一樣,針對(duì)文件所屬于的用戶組,find命令也具有同樣的選項(xiàng),為了在/apps目錄下查找屬于gem用戶組的文件,可以用:
find/apps-groupgem-print
要查找沒有有效所屬用戶組的所有文件,可以使用nogroup選項(xiàng)。下面的find命令從文件系統(tǒng)的根目錄處查找這樣的文件:
find/-nogroup-print
7.按照更改時(shí)間或訪問時(shí)間等查找文件:
如果希望按照更改時(shí)間來(lái)查找文件,可以使用mtime,atime或ctime選項(xiàng)。如果系統(tǒng)突然沒有可用空間了,很有可能某一個(gè)文件的長(zhǎng)度在此期間增長(zhǎng)迅速,這時(shí)就可以用mtime選項(xiàng)來(lái)查找這樣的文件。
用減號(hào)-來(lái)限定更改時(shí)間在距今n日以內(nèi)的文件,而用加號(hào)+來(lái)限定更改時(shí)間在距今n日以前的文件。
希望在系統(tǒng)根目錄下查找更改時(shí)間在5日以內(nèi)的文件,可以用:
find/-mtime-5-print
為了在/var/adm目錄下查找更改時(shí)間在3日以前的文件,可以用:
find/var/adm-mtime+3-print
8.查找比某個(gè)文件新或舊的文件:
如果希望查找更改時(shí)間比某個(gè)文件新但比另一個(gè)文件舊的所有文件,可以使用-newer選項(xiàng)。
它的一般形式為:
newest_file_name!oldest_file_name
其中,!是邏輯非符號(hào)。
實(shí)例1:查找更改時(shí)間比文件log2012.log新但比文件log2017.log舊的文件
命令:
find-newerlog2012.log!-newerlog2017.log
輸出:
[root@localhosttest]#ll
總計(jì)316
-rw-r--r--1rootroot30210811-1306:03log2012.log
-rw-r--r--1rootroot6111-1306:03log2013.log
-rw-r--r--1rootroot011-1306:03log2014.log
-rw-r--r--1rootroot011-1306:06log2015.log
-rw-r--r--1rootroot011-1614:41log2016.log
-rw-r--r--1rootroot011-1614:43log2017.log
drwxr-xr-x6rootroot409610-2701:58scf
drwxrwxr-x2rootroot409611-1306:08test3
drwxrwxr-x2rootroot409611-1305:50test4
[root@localhosttest]#find-newerlog2012.log!-newerlog2017.log
.
./log2015.log
./log2017.log
./log2016.log
./test3
[root@localhosttest]#
實(shí)例2:查找更改時(shí)間在比log2012.log文件新的文件
命令:
find.-newerlog2012.log-print
輸出:
[root@localhosttest]#find-newerlog2012.log
.
./log2015.log
./log2017.log
./log2016.log
./test3
[root@localhosttest]#
9.使用type選項(xiàng):
實(shí)例1:在/etc目錄下查找所有的目錄
命令:
find/etc-typed-print
實(shí)例2:在當(dāng)前目錄下查找除目錄以外的所有類型的文件
命令:
find.!-typed-print
實(shí)例3:在/etc目錄下查找所有的符號(hào)鏈接文件
命令:
find/etc-typel-print
10.使用size選項(xiàng):
可以按照文件長(zhǎng)度來(lái)查找文件,這里所指的文件長(zhǎng)度既可以用塊(block)來(lái)計(jì)量,也可以用字節(jié)來(lái)計(jì)量。以字節(jié)計(jì)量文件長(zhǎng)度的表達(dá)形式為Nc;以塊計(jì)量文件長(zhǎng)度只用數(shù)字表示即可。
在按照文件長(zhǎng)度查找文件時(shí),一般使用這種以字節(jié)表示的文件長(zhǎng)度,在查看文件系統(tǒng)的大小,因?yàn)檫@時(shí)使用塊來(lái)計(jì)量更容易轉(zhuǎn)換。
實(shí)例1:在當(dāng)前目錄下查找文件長(zhǎng)度大于1M字節(jié)的文件
命令:
find.-size+1000000c-print
實(shí)例2:在/home/apache目錄下查找文件長(zhǎng)度恰好為100字節(jié)的文件:
命令:
find/home/apache-size100c-print
實(shí)例3:在當(dāng)前目錄下查找長(zhǎng)度超過(guò)10塊的文件(一塊等于512字節(jié))
命令:
find.-size+10-print
11.使用depth選項(xiàng):
在使用find命令時(shí),可能希望先匹配所有的文件,再在子目錄中查找。使用depth選項(xiàng)就可以使find命令這樣做。這樣做的一個(gè)原因就是,當(dāng)在使用find命令向磁帶上備份文件系統(tǒng)時(shí),希望首先備份所有的文件,其次再備份子目錄中的文件。
實(shí)例1:find命令從文件系統(tǒng)的根目錄開始,查找一個(gè)名為CON.FILE的文件。
命令:
find/-name"CON.FILE"-depth-print
說(shuō)明:
它將首先匹配所有的文件然后再進(jìn)入子目錄中查找
12.使用mount選項(xiàng):
在當(dāng)前的文件系統(tǒng)中查找文件(不進(jìn)入其他文件系統(tǒng)),可以使用find命令的mount選項(xiàng)。
實(shí)例1:從當(dāng)前目錄開始查找位于本文件系統(tǒng)中文件名以XC結(jié)尾的文件
命令:
find.-name"*.XC"-mount-print
13、
查當(dāng)前目錄下的所有普通文件,并在- e x e c選項(xiàng)中使用ls -l命令將它們列出
# find . -type f -exec ls -l {} /;-rw-r–r– 1 root root 34928 2003-02-25 ./conf/httpd.conf-rw-r–r– 1 root root 12959 2003-02-25 ./conf/magic-rw-r–r– 1 root root 180 2003-02-25 ./conf.d/README
14、 ok選項(xiàng)查詢文件并詢問是否要顯示[root@book class]# find ./ -mtime -1 -type f -ok ls -l {} /;< ls … ./classDB.inc.php > ? y-rw-r–r– 1 cnscn cnscn 13709 1月 12 12:22 ./classDB.inc.php[root@book class]# find ./ -mtime -1 -type f -ok ls -l {} /;< ls … ./classDB.inc.php > ? n[root@book class]#
find / -name filename -exec rm -rf {} /; find / -name filename -ok rm -rf {} /;
15、查詢并交給awk去處理[root@book class]# who | awk ’{print $1"/t"$2}’cnscn pts/0
=================================================awk—grep—sed
[root@book class]# df -k | awk ‘{print $1}’ | grep -v ’none’ | sed s"http:///dev////g"文件系統(tǒng)sda2sda1[root@book class]# df -k | awk ‘{print $1}’ | grep -v ’none’文件系統(tǒng)/dev/sda2/dev/sda1
三、 find命令答疑
我用find / -name filename| rm -rf,不成功,請(qǐng)問為什么不成功?
find / -name filename -exec rm -rf {} /;find . -name filename |rm -rf試一下{} 表示你找出來(lái)的結(jié)果。/; 則相當(dāng)于“憲法”,沒什么說(shuō)頭,就是這么規(guī)定的,在 -exec 后面需要一個(gè)表示該命令終結(jié)的的符號(hào)。可以在 man find 中找到答案。要讓rm識(shí)別find的結(jié)果,如下:find / -name filename |xargs rm -rf之所以find . -name filename |rm -rf不通過(guò),是因?yàn)閞m命令不接受從標(biāo)準(zhǔn)輸入傳過(guò)來(lái)的指令查找含特定字符串的文件例如查找當(dāng)前目錄下含有"the string you want find…"字符串的文件:$find . -type f -exec grep “the string you want find…” {} ; -print
四、自己的使用經(jīng)歷
1、find輸出幾個(gè)文件的具體修改時(shí)間
[afc@xingzhengzhongxin Exp]$ ls Para.1106.* Para.1107.* Para.1109.* -al-rw-r--r-- 1 afc aas 5178 Apr 11 22:30 Para.1106.00000227.77.00-rw-r--r-- 1 afc aas 22043 Apr 11 22:30 Para.1107.00000227.77.00-rw-r--r-- 1 afc aas 7410 Apr 11 22:30 Para.1109.00000227.77.00[afc@xingzhengzhongxin Exp]$ ls Para.1106.* Para.1107.* Para.1109.* -al --time-style "+%Y-%m-%d %H:%M:%S"|awk '{print $8"/t"$6" "$7}'Para.1106.00000227.77.00 2014-04-11 22:30:44Para.1107.00000227.77.00 2014-04-11 22:30:45Para.1109.00000227.77.00 2014-04-11 22:30:46[afc@xingzhengzhongxin Exp]$ ls -l|find /AFC/Data/Para/Exp/ -name "Para.1106.*" -o -name "Para.1108.*" -o -name "Para.1109.*" /AFC/Data/Para/Exp/Para.1108.00000227.77.00/AFC/Data/Para/Exp/Para.1106.00000227.77.00/AFC/Data/Para/Exp/Para.1109.00000227.77.00[afc@xingzhengzhongxin Exp]$ find /AFC/Data/Para/Exp/ -name "Para.1106.*" -ls -o -name "Para.1108.*" -ls -o -name "Para.1109.*" -ls|sort -n3473431 12 -rw-r--r-- 1 afc aas 5178 Apr 11 22:30 /AFC/Data/Para/Exp/Para.1106.00000227.77.003473433 8 -rw-r--r-- 1 afc aas 3670 Apr 11 22:30 /AFC/Data/Para/Exp/Para.1108.00000227.77.003473434 12 -rw-r--r-- 1 afc aas 7410 Apr 11 22:30 /AFC/Data/Para/Exp/Para.1109.00000227.77.00[afc@xingzhengzhongxin Exp]$ find /AFC/Data/Para/Exp/ -name "Para.1106.*" -ls -o -name "Para.1108.*" -ls -o -name "Para.1109.*" -ls|sort -n|awk -F '/' '{print $6}'Para.1106.00000227.77.00Para.1108.00000227.77.00Para.1109.00000227.77.00[afc@beiyuanzhan ~]$ find /AFC/Data/Para/Exp/ -name "Para.1106.*" -o -name "Para.1108.*" -o -name "Para.1109.*"|xargs ls -l --time-style "+%Y-%m-%d %H:%M:%S"-rw-r--r-- 1 afc aas 5178 2014-04-15 09:08:14 /AFC/Data/Para/Exp/Para.1106.00000223.77.00-rw-r--r-- 1 afc aas 3670 2014-04-15 09:08:15 /AFC/Data/Para/Exp/Para.1108.00000223.77.00-rw-r--r-- 1 afc aas 7410 2014-04-15 09:08:15 /AFC/Data/Para/Exp/Para.1109.00000223.77.00[root@fz ~]# find /AFC/params/ -name "Para.1106.*" -ls -o -name "Para.1108.*" -ls -o -name "Para.1109.*" -ls|sort -n|awk -F '/' '{print $4}'Para.1106.00000000.0000000077.00Para.1108.00000000.0000000077.002、
1901參數(shù)文件時(shí)間:ls /AFC/Data/Para/Exp/Para.1901.* --full-time|awk '{print $6"/t"$7}'|awk -F '.' '{print $1}'3、
2#LC發(fā)送數(shù)據(jù)包(不能獲取昨天日期)ls /AFC/Data/bak/$(date +%Y_%m_)25/Outer/Acc |wc -l= /AFC/Data/bak/2015_08_25/Outer/AccPACC服務(wù)器:pacc收1#find /AFC/Data/bak/$(date -d last-day +%Y_%m_%d)/Outer/Lc/ -name '*_62010001*' |wc -lpacc收2#find /AFC/Data/bak/$(date -d last-day +%Y_%m_%d)/Outer/Lc/ -name '*_62020001*' |wc -lpacc發(fā)送find /AFC/Data/Transaction/YKT_Snd/ -name "*`date -d last-day +%y%m%d`*" |wc -l
4、另一個(gè)ls命令輸出文件時(shí)間的寫法

1 [afc@beiyuanzhan ~]$ cd /AFC/Data/Para/Exp/ 2 [afc@beiyuanzhan Exp]$ ls 3 Para.1002.00000223.1293.00 Para.1011.00000223.6.00 Para.1101.00000223.6.00 Para.1108.00000223.80.00 Para.1919.00000223.20130307.00 4 Para.1005.00000223.1.00 Para.1021.00000223.3.00 Para.1102.00000223.2.00 Para.1109.00000223.80.00 Para.1920.00000223.2.00 5 Para.1006.00000223.1732.00 Para.1031.00000223.8.00 Para.1103.00000223.77.00 Para.1901.00000223.20150812.00 Para.1921.00000223.1.00 6 Para.1007.01022300.195.00 Para.1041.00000223.2.00 Para.1104.00000223.548.00 Para.1912.00000223.20130307.00 7 Para.1007.02022300.195.00 Para.1089.00000223.5.00 Para.1105.00000223.77.00 Para.1913.00000223.20130307.00 8 Para.1007.1F022300.195.00 Para.1090.00000223.431.00 Para.1106.00000223.79.00 Para.1914.00000223.20130307.00 9 Para.1007.33022300.195.00 Para.1097.00000223.1.00 Para.1107.00000223.77.00 Para.1918.00000223.20110913.0010 [afc@beiyuanzhan Exp]$ ls -l11 total 36812 -rw-r--r-- 1 afc aas 102 Jun 12 06:35 Para.1002.00000223.1293.0013 -rw-r--r-- 1 afc aas 136 Jun 12 06:35 Para.1005.00000223.1.0014 -rw-r--r-- 1 afc aas 2664 Aug 12 18:51 Para.1006.00000223.1732.0015 -rw-r--r-- 1 afc aas 1934 Aug 9 02:02 Para.1007.01022300.195.0016 -rw-r--r-- 1 afc aas 1966 Aug 9 02:02 Para.1007.02022300.195.0017 -rw-r--r-- 1 afc aas 1838 Aug 9 02:02 Para.1007.1F022300.195.0018 -rw-r--r-- 1 afc aas 1790 Aug 9 02:02 Para.1007.33022300.195.0019 -rw-r--r-- 1 afc aas 226 Jun 12 06:35 Para.1011.00000223.6.0020 -rw-r--r-- 1 afc aas 144 Jun 12 06:35 Para.1021.00000223.3.0021 -rw-r--r-- 1 afc aas 410 Jun 12 06:35 Para.1031.00000223.8.0022 -rw-r--r-- 1 afc aas 108 Jun 12 06:35 Para.1041.00000223.2.0023 -rw-r--r-- 1 afc aas 119 Jun 12 06:35 Para.1089.00000223.5.0024 -rw-r--r-- 1 afc aas 1776 Jun 12 06:35 Para.1090.00000223.431.0025 -rw-r--r-- 1 afc aas 204 Jun 12 06:35 Para.1097.00000223.1.0026 -rw-r--r-- 1 afc aas 905 Jun 12 06:35 Para.1101.00000223.6.0027 -rw-r--r-- 1 afc aas 1159 Jun 12 06:35 Para.1102.00000223.2.0028 -rw-r--r-- 1 afc aas 764 Jun 12 06:35 Para.1103.00000223.77.0029 -rw-r--r-- 1 afc aas 19598 Aug 13 02:03 Para.1104.00000223.548.0030 -rw-r--r-- 1 afc aas 5763 Jun 12 06:35 Para.1105.00000223.77.0031 -rw-r--r-- 1 afc aas 5658 Jun 12 06:35 Para.1106.00000223.79.0032 -rw-r--r-- 1 afc aas 22043 Jun 12 06:35 Para.1107.00000223.77.0033 -rw-r--r-- 1 afc aas 4342 Jun 12 06:35 Para.1108.00000223.80.0034 -rw-r--r-- 1 afc aas 8018 Jun 12 06:35 Para.1109.00000223.80.0035 -rw-r--r-- 1 afc aas 65876 Aug 13 03:13 Para.1901.00000223.20150812.0036 -rw-r--r-- 1 afc aas 400 Jun 12 06:35 Para.1912.00000223.20130307.0037 -rw-r--r-- 1 afc aas 278 Jun 12 06:35 Para.1913.00000223.20130307.0038 -rw-r--r-- 1 afc aas 413 Jun 12 06:35 Para.1914.00000223.20130307.0039 -rw-r--r-- 1 afc aas 252 Jun 12 06:35 Para.1918.00000223.20110913.0040 -rw-r--r-- 1 afc aas 233 Jun 12 06:35 Para.1919.00000223.20130307.0041 -rw-r--r-- 1 afc aas 80 Jun 12 06:35 Para.1920.00000223.2.0042 -rw-r--r-- 1 afc aas 80 Jun 12 06:35 Para.1921.00000223.1.0043 44 [afc@beiyuanzhan Exp]$ ls /AFC/Data/Para/Exp/*45 /AFC/Data/Para/Exp/Para.1002.00000223.1293.00 /AFC/Data/Para/Exp/Para.1089.00000223.5.00 /AFC/Data/Para/Exp/Para.1109.00000223.80.0046 /AFC/Data/Para/Exp/Para.1005.00000223.1.00 /AFC/Data/Para/Exp/Para.1090.00000223.431.00 /AFC/Data/Para/Exp/Para.1901.00000223.20150812.0047 /AFC/Data/Para/Exp/Para.1006.00000223.1732.00 /AFC/Data/Para/Exp/Para.1097.00000223.1.00 /AFC/Data/Para/Exp/Para.1912.00000223.20130307.0048 /AFC/Data/Para/Exp/Para.1007.01022300.195.00 /AFC/Data/Para/Exp/Para.1101.00000223.6.00 /AFC/Data/Para/Exp/Para.1913.00000223.20130307.0049 /AFC/Data/Para/Exp/Para.1007.02022300.195.00 /AFC/Data/Para/Exp/Para.1102.00000223.2.00 /AFC/Data/Para/Exp/Para.1914.00000223.20130307.0050 /AFC/Data/Para/Exp/Para.1007.1F022300.195.00 /AFC/Data/Para/Exp/Para.1103.00000223.77.00 /AFC/Data/Para/Exp/Para.1918.00000223.20110913.0051 /AFC/Data/Para/Exp/Para.1007.33022300.195.00 /AFC/Data/Para/Exp/Para.1104.00000223.548.00 /AFC/Data/Para/Exp/Para.1919.00000223.20130307.0052 /AFC/Data/Para/Exp/Para.1011.00000223.6.00 /AFC/Data/Para/Exp/Para.1105.00000223.77.00 /AFC/Data/Para/Exp/Para.1920.00000223.2.0053 /AFC/Data/Para/Exp/Para.1021.00000223.3.00 /AFC/Data/Para/Exp/Para.1106.00000223.79.00 /AFC/Data/Para/Exp/Para.1921.00000223.1.0054 /AFC/Data/Para/Exp/Para.1031.00000223.8.00 /AFC/Data/Para/Exp/Para.1107.00000223.77.0055 /AFC/Data/Para/Exp/Para.1041.00000223.2.00 /AFC/Data/Para/Exp/Para.1108.00000223.80.0056 [afc@beiyuanzhan Exp]$ ls /AFC/Data/Para/Exp/Para.1901.*57 /AFC/Data/Para/Exp/Para.1901.00000223.20150812.0058 [afc@beiyuanzhan Exp]$ ls /AFC/Data/Para/Exp/Para.1901.* --full-time 59 -rw-r--r-- 1 afc aas 65876 2015-08-13 03:13:23.000000000 +0800 /AFC/Data/Para/Exp/Para.1901.00000223.20150812.0060 [afc@beiyuanzhan Exp]$ ls /AFC/Data/Para/Exp/Para.1901.* --full-time|awk '{print $6"/t"$7}'61 2015-08-13 03:13:23.00000000062 [afc@beiyuanzhan Exp]$ ls /AFC/Data/Para/Exp/Para.1901.* --full-time|awk '{print $6"/t"$7}'|awk -F '.' '{print $1}'63 2015-08-13 03:13:2364 [afc@beiyuanzhan Exp]$ ls /AFC/Data/Para/Exp/Para.1901.* --full-time|awk '{print $6"/t"$7"/t"$9}'65 2015-08-13 03:13:23.000000000 /AFC/Data/Para/Exp/Para.1901.00000223.20150812.0066 [afc@beiyuanzhan Exp]$ ls /AFC/Data/Para/Exp/Para.1901.* --full-time|awk '{print $6"/t"$7"/t"$9}'|awk -F '.' '{print $1"/t"$3}'67 2015-08-13 03:13:23 190168 [afc@beiyuanzhan Exp]$ View Code新聞熱點(diǎn)
疑難解答
圖片精選