1.按大小排序
[[email protected] ~]$ ll -Sh
total 2.6G
-rw-r----- 1 oracle oinstall 1.1G Apr 30
01:05 example_01.dbf
-rw-r--r-- 1 oracle oinstall 519M Apr 23
07:35 full.dmp
-rw-r----- 1 oracle oinstall 498M Apr 30
11:47 undotbs02.dbf
-rw-r--r-- 1 oracle oinstall 409M Apr 22
16:45 hr.dmp
-rw-r--r-- 1 oracle oinstall 33M Apr 23 07:54 fullimp.log
-rw-r----- 1 oracle oinstall 33M Apr 30 01:05 zyx_01.dbf
2.按時間排序
[[email protected] ~]$ ll -rth
total 2.6G
-rw-r----- 1 oracle oinstall 33M Apr 23 03:43 temp01.dbf
-rw-r--r-- 1 oracle oinstall 519M Apr 23
07:35 full.dmp
-rw-r--r-- 1 oracle oinstall 33M Apr 23 07:54 fullimp.log
-rw-r--r-- 1 oracle oinstall 4.0K Apr 27
00:51 hrimp.log
-rw-r----- 1 oracle oinstall 9.4M Apr 27
03:03 02r425b7_1_1.ctl
-rw-r----- 1 oracle oinstall 33M Apr 27 21:19 temp2.dbf
-rw-r----- 1 oracle oinstall 33M Apr 27 21:20 temp1.dbf
3.統計目前檔案夾下檔案的個數
[[email protected] ~]$ ll |grep "^"|wc
-l
36
4.統計目前檔案夾下目錄的個數
[[email protected] ~]$ ll |grep "^d"|wc
-l
2
5.統計檔案夾下目錄的個數,包括子檔案夾裡的
[[email protected] ~]$ ls -lR
/u01/app/oracle/|grep "^d"|wc -l
3162
6.統計/home/oracle目錄(包含子目錄)下的所有temp檔案則:
[[email protected] ~]$ ls /home/oracle/temp*
/home/oracle/temp01.dbf /home/oracle/temp1.dbf /home/oracle/temp2.dbf
[[email protected] ~]$ ls -lR /home/oracle/ |grep
temp|wc -l
3
7.查找/home/oracle目錄下(保護子目錄)下scott檔案,并做統計
[[email protected] ~]$ ls -lR /home/oracle/|grep
scott
-rw-r--r-- 1 oracle oinstall 24576 Apr 29 01:29 scott.dmp
-rw-r--r-- 1 oracle oinstall 1497 Apr 29 01:29 scott_log.log
-rw-r----- 1 oracle oinstall 266240 Apr 29
01:36 scott1.dmp
-rw-r----- 1 oracle oinstall 282624 Apr 28
19:56 scott.dmp
[[email protected] ~]$ ls -lR /home/oracle/|grep
scott|wc -l
4
8.查找alertORACLE_SID.log (oracle告警日志)
[[email protected] ~]$ find $ORACLE_BASE -name
alert*.log
/u01/app/oracle/diag/rdbms/orcl/test/trace/alert_test.log
9.grep查詢
grep [選項參數]“要查找的内容字元串"路徑
-r:遞歸查找子目錄
-l:隻顯示檔案名
./:目前目錄路徑
查詢檔案中包含"EXP"字元的檔案
[[email protected] ~]$ grep -rl "EXP" ./
./dump/fulldp.log
./hrimp.log
./scottimp.log
./expdp/export.log
./scottimp1.log
./hrimp1.log
./fullimp.log
./.bash_history
如果想把"./"和"/"去掉,可以利用sed
[[email protected] ~]$ grep -rl "EXP" ./
|sed "s;./;;g"
dumpfulldp.log
hrimp.log
scottimp.log
expdpexport.log
scottimp1.log
hrimp1.log
fullimp.log
.bash_history
如果隻想把"./"去掉,如下,需要用到"\"将"."轉義
[[email protected] ~]$ grep -rl "EXP" ./
|sed "s;\./;;g"
或
[[email protected] ~]$ grep -rl "EXP" ./
|awk -F'\\./' '{print $2}'
dump/fulldp.log
hrimp.log
scottimp.log
expdp/export.log
scottimp1.log
hrimp1.log
fullimp.log
.bash_history