강좌
클라우드/리눅스에 관한 강좌입니다.
리눅스 분류

ls로 파일리스트를 표시할 때 파일의 용량별로 내림차순 정렬하여 보여주기

작성자 정보

  • 관리자 작성
  • 작성일

컨텐츠 정보

본문

ls로 파일리스트를 표시할 때 파일의 용량별로 내림차순 정렬하여 보여주기

 

현재 디렉토리내에 존재하는 파일들의 리스트를 ls명령어로 출력하면서 파일의 용량크기에 따른 정렬을 하여 나열할 수 있습니다.

 

 

 

  파일의 용량별로 정렬하여 출력하는 방법은 디스크의 용량관리에 매우 큰 도움이 됩니다.

 

 

 

  , 일반 계정사용자들이 사용하는 전체 공간을 대상으로 파일용량에 따른 내림차순 또는 오름차순으로 정렬하여 나열 할 수 있기 때문입니다.

 

 

 

 

 

ls명령어에서 파일의 용량별로 정렬을 해주는 옵션은 -S옵션이므로 용량별로 정렬을 하려면 반드시 -S옵션을 사용해야 합니다.

 

 

 

 

 

용량을 기준으로 내림차순 정렬이란 용량이 큰 파일부터 작은 파일 순으로 차례대로 출력되는 것을 의미합니다.

 

 

 

 

 

일반 계정사용자에게도 매우 중요한 옵션이지만 특히 여러분들께서 시스템을 관리하는 시스템관리자라면 파일의 용량별로 정렬하여 출력하는 방법을 꼭 기억해 두시기 바랍니다.

 

 

 

  디스크의 용량관리에 굉장히 큰 도움이 될 것입니다.

 

 

 

 

 

다음 예는 현재 디렉토리내에 존재하는 파일들의 용량을 기준으로 내림차순으로 정렬하여 출력한 것입니다.

 

 

 

 파일의 용량크기를 비교하면서 확인해 보시기 바랍니다.

 

 

 

 

 

[root@su250 ~]# ls -lS

합계 60

-rw-r--r-- 1 root root 17504 2008-12-2320:41 README

drwxr-xr-x 2 root root  4096 2008-12-2319:17 html

drwxr-xr-x 4 root root  4096 2008-12-2222:02 httpd

drwxr-xr-x 4 root root  4096 2008-12-2222:02 httpd2

drwxr-xr-x 3 root root  4096 2008-12-2323:46 link

-rwxr-xr-x 1 root root   574 2008-12-2319:29 website

-rw-r--r-- 1 root root   408 2008-12-2317:20 apache.txt

-rw-r--r-- 1 root root    68 2008-12-2322:59 file

-rw-r--r-- 1 root root    60 2008-12-2220:59 file2

-rwxr-xr-x 1 root root    53 2008-12-2220:58 file1

-rw-r--r-- 1 root root    53 2008-12-2221:01 file3

[root@su250 ~]#

 

다음은 현재 디렉토리내의 .()으로 시작되는 파일들을 포함한 모든 파일들을 대상으로 파일들의 용량을 기준으로 내림차순으로 정렬하여 출력한 것입니다.

 

 

 

 

 

-S옵션과 함께  -a옵션을 사용하는 것은 숨겨진 큰 파일을 찾아내기 위한 목적으로 사용한 것입니다.

 

 

 

 

 

[root@su250 ~]# ls -alS

합계 160

-rw-------  1 root root 17581 2008-12-2304:14 .bash_history

-rw-r--r--  1 root root 17504 2008-12-2320:41 README

drwxr-x--- 14 root root  4096 2008-12-2322:59 .

drwxr-xr-x 26 root root  4096 2008-12-2317:08 ..

drwx------  2 root root  4096 2008-12-0201:51 .chewing

drwx------  3 root root  4096 2008-12-0200:50 .dbus

drwx------  3 root root  4096 2008-12-0201:51 .gconf

drwx------  2 root root  4096 2008-12-0201:51 .gconfd

drwx------  3 root root  4096 2008-12-0201:01 .gnome2

drwx------  2 root root  4096 2008-12-0200:50 .gnome2_private

drwxr-xr-x  2 root root  4096 2008-12-0201:50 .gstreamer-0.10

drwx------  3 root root  4096 2008-12-0201:51 .scim

drwxr-xr-x  2 root root  4096 2008-12-2319:17 html

drwxr-xr-x  4 root root  4096 2008-12-2222:02 httpd

drwxr-xr-x  4 root root  4096 2008-12-2222:02 httpd2

drwxr-xr-x  3 root root  4096 2008-12-2323:46 link

-rw-r--r--  1 root root   617 2008-12-0302:05 .toprc

-rwxr-xr-x  1 root root   574 2008-12-2319:29 website

-rw-r--r--  1 root root   408 2008-12-2317:20 apache.txt

-rw-------  1 root root   218 2008-12-0201:51 .recently-used.xbel

-rw-r--r--  1 root root   204 2008-12-0402:11 .bash_profile

-rw-r--r--  1 root root   176 2006-07-1309:06 .bashrc

-rw-r--r--  1 root root   129 2006-07-1309:06 .tcshrc

-rw-------  1 root root   106 2008-12-2303:35 .lesshst

-rw-r--r--  1 root root   100 2006-07-1309:06 .cshrc

-rw-r--r--  1 root root    68 2008-12-2322:59 file

-rw-r--r--  1 root root    60 2008-12-2220:59 file2

-rw-------  1 root root    54 2008-12-0201:47 .xauth8ECJIu

-rwxr-xr-x  1 root root    53 2008-12-2220:58 file1

-rw-r--r--  1 root root    53 2008-12-2221:01 file3

-rw-r--r--  1 root root    24 2006-07-1309:06 .bash_logout

[root@su250 ~]#

 

그리고 다음은 현재 디렉토리내의 .()으로 시작되는 파일들과 현재 디렉토리내의 서브디렉토리의 파일들까지 모든 파일들을 대상으로 파일들의 용량을 기준으로 내림차순으로 정렬하여 출력한 것입니다.

 

 

 

 

 

[root@su250 ~]# ls -alSR

.:

합계 160

-rw-------  1 root root 17581 2008-12-2304:14 .bash_history

-rw-r--r--  1 root root 17504 2008-12-2320:41 README

drwxr-x--- 14 root root  4096 2008-12-2322:59 .

drwxr-xr-x 26 root root  4096 2008-12-2317:08 ..

drwx------  2 root root  4096 2008-12-0201:51 .chewing

drwx------  3 root root  4096 2008-12-0200:50 .dbus

drwx------  3 root root  4096 2008-12-0201:51 .gconf

drwx------  2 root root  4096 2008-12-0201:51 .gconfd

drwx------  3 root root  4096 2008-12-0201:01 .gnome2

drwx------  2 root root  4096 2008-12-0200:50 .gnome2_private

drwxr-xr-x  2 root root  4096 2008-12-0201:50 .gstreamer-0.10

drwx------  3 root root  4096 2008-12-0201:51 .scim

drwxr-xr-x  2 root root  4096 2008-12-2319:17 html

drwxr-xr-x  4 root root  4096 2008-12-2222:02 httpd

drwxr-xr-x  4 root root  4096 2008-12-2222:02 httpd2

drwxr-xr-x  3 root root  4096 2008-12-2323:46 link

-rw-r--r--  1 root root   617 2008-12-0302:05 .toprc

-rwxr-xr-x  1 root root   574 2008-12-2319:29 website

-rw-r--r--  1 root root   408 2008-12-2317:20 apache.txt

-rw-------  1 root root   218 2008-12-0201:51 .recently-used.xbel

-rw-r--r--  1 root root   204 2008-12-0402:11 .bash_profile

-rw-r--r--  1 root root   176 2006-07-1309:06 .bashrc

-rw-r--r--  1 root root   129 2006-07-1309:06 .tcshrc

-rw-------  1 root root   106 2008-12-2303:35 .lesshst

-rw-r--r--  1 root root   100 2006-07-1309:06 .cshrc

-rw-r--r--  1 root root    68 2008-12-2322:59 file

-rw-r--r--  1 root root    60 2008-12-2220:59 file2

-rw-------  1 root root    54 2008-12-0201:47 .xauth8ECJIu

-rwxr-xr-x  1 root root    53 2008-12-2220:58 file1

-rw-r--r--  1 root root    53 2008-12-2221:01 file3

-rw-r--r--  1 root root    24 2006-07-1309:06 .bash_logout

 

./.chewing:

합계 12

drwx------  2 root root 4096 2008-12-0201:51 .

drwxr-x--- 14 root root 4096 2008-12-2322:59 ..

-rw-r--r--  1 root root    8 2008-12-0201:51 uhash.dat

 

./.dbus:

합계 12

drwx------  3 root root 4096 2008-12-0200:50 .

drwxr-x--- 14 root root 4096 2008-12-2322:59 ..

drwx------  2 root root 4096 2008-12-0200:50 session-bus

 

./.dbus/session-bus:

합계 12

drwx------ 2 root root 4096 2008-12-0200:50 .

drwx------ 3 root root 4096 2008-12-0200:50 ..

-rw-r--r-- 1 root root  466 2008-12-0201:51 fa160651e87369ff3307a3f64933e534-0

 

./.gconf:

합계 12

drwx------  3 root root 4096 2008-12-0201:51 .

drwxr-x--- 14 root root 4096 2008-12-2322:59 ..

drwx------  3 root root 4096 2008-12-0201:51 apps

 

./.gconf/apps:

합계 12

drwx------ 3 root root 4096 2008-12-0201:51 .

drwx------ 3 root root 4096 2008-12-0201:51 ..

drwx------ 2 root root 4096 2008-12-0201:51 sound-juicer

-rw------- 1 root root    0 2008-12-0201:51 %gconf.xml

 

./.gconf/apps/sound-juicer:

합계 12

drwx------ 2 root root 4096 2008-12-0201:51 .

drwx------ 3 root root 4096 2008-12-0201:51 ..

-rw------- 1 root root  421 2008-12-0201:51 %gconf.xml

 

./.gconfd:

합계 8

drwx------  2 root root 4096 2008-12-0201:51 .

drwxr-x--- 14 root root 4096 2008-12-2322:59 ..

-rwx------  1 root root    0 2008-12-0201:51 saved_state

 

./.gnome2:

합계 16

drwx------  3 root root 4096 2008-12-0201:01 .

drwxr-x--- 14 root root 4096 2008-12-2322:59 ..

drwx------  2 root root 4096 2008-12-0200:50 accels

-rw-r--r--  1 root root  115 2008-12-0201:01 system-config-network

이하생략

 

-S옵션과 -a옵션, -R옵션을 사용하여 서브디렉토리의 내용까지 모든 파일의 용량을 기준으로 정렬한 것은 특정 디렉토리 이하의 모든 내용을 대상으로 점검하기 위한 목적으로 사용합니다.

 

 

 

 

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,040 명
  • 현재 강좌수 :  35,853 개
  • 현재 접속자 :  156 명