歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

linux下查看文件夾及其排序的bash語法

1. 文件夾大小排序

統計當前目錄大小

[oracle@oracledb~]$ du -sk

526496 .

該目錄下所有子目錄大小統計並排序

[oracle@oracledb~]$ du -k | sort -rn

526496 .

457552 ./rda

384248 ./rda/output

45760 ./rda/ccr

7720 ./rda/modules

7024 ./rda/da

6536 ./rda/engine

4384 ./rda/da/lib

3300 ./rda/hcve

2600 ./rda/RDA

1892 ./rda/da/docs

928 ./rda/RDA/Object

636 ./rda/da/menus

440 ./rda/RDA/Library

228 ./rda/RDA/Driver

96 ./rda/RDA/Value

88 ./rda/output/extern

76 ./rda/RDA/Handle

68 ./rda/RDA/Operator

64 ./rda/Convert

60 ./rda/da/bin

48 ./rda/RDA/Web

48 ./rda/IRDA

44 ./rda/RDA/Local

40 ./rda/RDA/Extern

40 ./rda/da/config

36 ./rda/RDA/Archive

24 ./rda/IRDA/CV0100

20 ./rda/dfw

16 ./rda/dfw/cv0100

12 ./rda/Convert/S100OS

12 ./.mozilla

12 ./.kde

8 ./rda/Convert/TSTALERT

8 ./rda/Convert/S362OIM

8 ./rda/Convert/S204LOG

8 ./rda/Convert/S130INST

8 ./rda/Convert/S010CFG

8 ./rda/Convert/Common

8 ./.kde/Autostart

8 ./amdu_2014_02_18_09_36_04

4 ./test

4 ./rda/output/TMP_RDA

4 ./rda/output/JOB_RDA

4 ./.mozilla/plugins

4 ./.mozilla/extensions

一級目錄大小

[oracle@oracledb~]$ du -k --max-depth=1

12 ./.kde

8 ./amdu_2014_02_18_09_36_04

12 ./.mozilla

457552 ./rda

4 ./test

526496 .

二級目錄大小

[oracle@oracledb~]$ du -k --max-depth=2

8 ./.kde/Autostart

12 ./.kde

8 ./amdu_2014_02_18_09_36_04

4 ./.mozilla/plugins

4 ./.mozilla/extensions

12 ./.mozilla

7720 ./rda/modules

48 ./rda/IRDA

20 ./rda/dfw

3300 ./rda/hcve

7024 ./rda/da

64 ./rda/Convert

6536 ./rda/engine

45760 ./rda/ccr

2600 ./rda/RDA

384248 ./rda/output

457552 ./rda

4 ./test

526496 .

二級目錄大小並排序

[oracle@oracledb~]$ du -k --max-depth=2 | sort -rn

526496 .

457552 ./rda

384248 ./rda/output

45760 ./rda/ccr

7720 ./rda/modules

7024 ./rda/da

6536 ./rda/engine

3300 ./rda/hcve

2600 ./rda/RDA

64 ./rda/Convert

48 ./rda/IRDA

20 ./rda/dfw

12 ./.mozilla

12 ./.kde

8 ./.kde/Autostart

8 ./amdu_2014_02_18_09_36_04

4 ./test

4 ./.mozilla/plugins

4 ./.mozilla/extensions

2. 文件大小排序

方式一

[oracle@oracledb~]$ ls -lS

total68848

-rw-r--r-- 1 oracle oinstall 58786810 Sep 11 02:47p14557095_429_LINUX.zip

-rw-r--r-- 1 oracle oinstall 10359119 Nov 29 04:36test.txt

-rw-r--r-- 1 oracle oinstall 340029 Nov 29 04:26 sqluldr.zip

-rw-r--r-- 1 oracle oinstall 214016 Mar 13 2013 sqluldr264.exe

-rw-r--r-- 1 oracle oinstall 185766 Mar 13 2013 sqluldr2_linux64_10204.bin

-rw-r--r-- 1 oracle oinstall 179200 Mar 13 2013 sqluldr2.exe

-rwxr--r-- 1 oracle oinstall 155171 Mar 13 2013 sqluldr2_linux32_10204.bin

-rwxr--r-- 1 oracle oinstall 63875 Dec 2 02:23 oratop

-rw-r--r-- 1 oracle oinstall 21141 Sep 10 02:41 batch_awr.tmp

-rw-r--r-- 1 oracle oinstall 10017 Aug 30 2013 bb.txt

-rw-r--r-- 1 oracle oinstall 7325 Aug 30 2013 aa.txt

-rw-r--r-- 1 oracle oinstall 7149 Sep 10 02:40 batch_awwrrpt.sql

-rw-r--r-- 1 oracle oinstall 4465 Sep 11 02:12 contig_free_space.lis

drwxr-xr-x 2 oracle oinstall 4096 Feb 18 09:36 amdu_2014_02_18_09_36_04

drwxr-xr-x12 oracle oinstall 4096 Sep 11 08:20rda

drwxr-xr-x 2 oracle oinstall 4096 Mar 7 20:30 test

-rw-r--r-- 1 oracle oinstall 1236 Dec 3 02:21 aa.ora

-rw-r--r-- 1 oracle oinstall 1195 Oct 12 02:36 11g.ora

-rw-r--r-- 1 oracle oinstall 1065 Sep 23 11:30 orcl.ora

-r--r--r-- 1 oracle oinstall 48 Sep 7 2012 readme.txt

方式二

[oracle@oracledb~]$ ls -lk | sort -k 5 –rn ---5指的是第五列

默認sort按照第一列排序

-rw-r--r-- 1 oracle oinstall 57409 Sep 11 02:47p14557095_429_LINUX.zip

-rw-r--r-- 1 oracle oinstall 10117 Nov 29 04:36 test.txt

-rw-r--r-- 1 oracle oinstall 333 Nov 29 04:26 sqluldr.zip

-rw-r--r-- 1 oracle oinstall 209 Mar 13 2013 sqluldr264.exe

-rw-r--r-- 1 oracle oinstall 182 Mar 13 2013 sqluldr2_linux64_10204.bin

-rw-r--r-- 1 oracle oinstall 175 Mar 13 2013 sqluldr2.exe

-rwxr--r-- 1 oracle oinstall 152 Mar 13 2013 sqluldr2_linux32_10204.bin

-rwxr--r-- 1 oracle oinstall 63 Dec 2 02:23 oratop

-rw-r--r-- 1 oracle oinstall 21 Sep 10 02:41 batch_awr.tmp

-rw-r--r-- 1 oracle oinstall 10 Aug 30 2013 bb.txt

-rw-r--r-- 1 oracle oinstall 8 Aug 30 2013 aa.txt

-rw-r--r-- 1 oracle oinstall 7 Sep 10 02:40 batch_awwrrpt.sql

-rw-r--r-- 1 oracle oinstall 5 Sep 11 02:12 contig_free_space.lis

drwxr-xr-x 2 oracle oinstall 4 Mar 7 20:30 test

drwxr-xr-x 2 oracle oinstall 4 Feb 18 09:36 amdu_2014_02_18_09_36_04

drwxr-xr-x12 oracle oinstall 4 Sep 11 08:20 rda

-rw-r--r-- 1 oracle oinstall 2 Sep 23 11:30 orcl.ora

-rw-r--r-- 1 oracle oinstall 2 Oct 12 02:36 11g.ora

-rw-r--r-- 1 oracle oinstall 2 Dec 3 02:21 aa.ora

-r--r--r-- 1 oracl

Copyright © Linux教程網 All Rights Reserved