ls로 파일리스트를 표시할 때 파일의 용량별로 내림차순 정렬하여 보여주기
작성자 정보
- 관리자 작성
- 작성일
컨텐츠 정보
- 2,971 조회
- 0 추천
- 목록
본문
ls로 파일리스트를 표시할 때 파일의 용량별로 내림차순 정렬하여 보여주기
현재 디렉토리내에 존재하는 파일들의 리스트를 ls명령어로 출력하면서 파일의 용량크기에 따른 정렬을 하여 나열할 수 있습니다.
파일의 용량별로 정렬하여 출력하는 방법은 디스크의 용량관리에 매우 큰 도움이 됩니다.
즉, 일반 계정사용자들이 사용하는 전체 공간을 대상으로 파일용량에 따른 내림차순 또는 오름차순으로 정렬하여 나열 할 수 있기 때문입니다.
ls명령어에서 파일의 용량별로 정렬을 해주는 옵션은 -S옵션이므로 용량별로 정렬을 하려면 반드시 -S옵션을 사용해야 합니다.
용량을 기준으로 내림차순 정렬이란 용량이 큰 파일부터 작은 파일 순으로 차례대로 출력되는 것을 의미합니다.
일반 계정사용자에게도 매우 중요한 옵션이지만 특히 여러분들께서 시스템을 관리하는 시스템관리자라면 파일의 용량별로 정렬하여 출력하는 방법을 꼭 기억해 두시기 바랍니다.
디스크의 용량관리에 굉장히 큰 도움이 될 것입니다.
다음 예는 현재 디렉토리내에 존재하는 파일들의 용량을 기준으로 내림차순으로 정렬하여 출력한 것입니다.
파일의 용량크기를 비교하면서 확인해 보시기 바랍니다.
[root@su250 ~]# ls -lS 합계 60 -rw-r--r-- 1 root root 17504 2008-12-23 20:41 README drwxr-xr-x 2 root root 4096 2008-12-23 19:17 html drwxr-xr-x 4 root root 4096 2008-12-22 22:02 httpd drwxr-xr-x 4 root root 4096 2008-12-22 22:02 httpd2 drwxr-xr-x 3 root root 4096 2008-12-23 23:46 link -rwxr-xr-x 1 root root 574 2008-12-23 19:29 website -rw-r--r-- 1 root root 408 2008-12-23 17:20 apache.txt -rw-r--r-- 1 root root 68 2008-12-23 22:59 file -rw-r--r-- 1 root root 60 2008-12-22 20:59 file2 -rwxr-xr-x 1 root root 53 2008-12-22 20:58 file1 -rw-r--r-- 1 root root 53 2008-12-22 21:01 file3 [root@su250 ~]# |
다음은 현재 디렉토리내의 .(점)으로 시작되는 파일들을 포함한 모든 파일들을 대상으로 파일들의 용량을 기준으로 내림차순으로 정렬하여 출력한 것입니다.
-S옵션과 함께 -a옵션을 사용하는 것은 숨겨진 큰 파일을 찾아내기 위한 목적으로 사용한 것입니다.
[root@su250 ~]# ls -alS 합계 160 -rw------- 1 root root 17581 2008-12-23 04:14 .bash_history -rw-r--r-- 1 root root 17504 2008-12-23 20:41 README drwxr-x--- 14 root root 4096 2008-12-23 22:59 . drwxr-xr-x 26 root root 4096 2008-12-23 17:08 .. drwx------ 2 root root 4096 2008-12-02 01:51 .chewing drwx------ 3 root root 4096 2008-12-02 00:50 .dbus drwx------ 3 root root 4096 2008-12-02 01:51 .gconf drwx------ 2 root root 4096 2008-12-02 01:51 .gconfd drwx------ 3 root root 4096 2008-12-02 01:01 .gnome2 drwx------ 2 root root 4096 2008-12-02 00:50 .gnome2_private drwxr-xr-x 2 root root 4096 2008-12-02 01:50 .gstreamer-0.10 drwx------ 3 root root 4096 2008-12-02 01:51 .scim drwxr-xr-x 2 root root 4096 2008-12-23 19:17 html drwxr-xr-x 4 root root 4096 2008-12-22 22:02 httpd drwxr-xr-x 4 root root 4096 2008-12-22 22:02 httpd2 drwxr-xr-x 3 root root 4096 2008-12-23 23:46 link -rw-r--r-- 1 root root 617 2008-12-03 02:05 .toprc -rwxr-xr-x 1 root root 574 2008-12-23 19:29 website -rw-r--r-- 1 root root 408 2008-12-23 17:20 apache.txt -rw------- 1 root root 218 2008-12-02 01:51 .recently-used.xbel -rw-r--r-- 1 root root 204 2008-12-04 02:11 .bash_profile -rw-r--r-- 1 root root 176 2006-07-13 09:06 .bashrc -rw-r--r-- 1 root root 129 2006-07-13 09:06 .tcshrc -rw------- 1 root root 106 2008-12-23 03:35 .lesshst -rw-r--r-- 1 root root 100 2006-07-13 09:06 .cshrc -rw-r--r-- 1 root root 68 2008-12-23 22:59 file -rw-r--r-- 1 root root 60 2008-12-22 20:59 file2 -rw------- 1 root root 54 2008-12-02 01:47 .xauth8ECJIu -rwxr-xr-x 1 root root 53 2008-12-22 20:58 file1 -rw-r--r-- 1 root root 53 2008-12-22 21:01 file3 -rw-r--r-- 1 root root 24 2006-07-13 09:06 .bash_logout [root@su250 ~]# |
그리고 다음은 현재 디렉토리내의 .(점)으로 시작되는 파일들과 현재 디렉토리내의 서브디렉토리의 파일들까지 모든 파일들을 대상으로 파일들의 용량을 기준으로 내림차순으로 정렬하여 출력한 것입니다.
[root@su250 ~]# ls -alSR .: 합계 160 -rw------- 1 root root 17581 2008-12-23 04:14 .bash_history -rw-r--r-- 1 root root 17504 2008-12-23 20:41 README drwxr-x--- 14 root root 4096 2008-12-23 22:59 . drwxr-xr-x 26 root root 4096 2008-12-23 17:08 .. drwx------ 2 root root 4096 2008-12-02 01:51 .chewing drwx------ 3 root root 4096 2008-12-02 00:50 .dbus drwx------ 3 root root 4096 2008-12-02 01:51 .gconf drwx------ 2 root root 4096 2008-12-02 01:51 .gconfd drwx------ 3 root root 4096 2008-12-02 01:01 .gnome2 drwx------ 2 root root 4096 2008-12-02 00:50 .gnome2_private drwxr-xr-x 2 root root 4096 2008-12-02 01:50 .gstreamer-0.10 drwx------ 3 root root 4096 2008-12-02 01:51 .scim drwxr-xr-x 2 root root 4096 2008-12-23 19:17 html drwxr-xr-x 4 root root 4096 2008-12-22 22:02 httpd drwxr-xr-x 4 root root 4096 2008-12-22 22:02 httpd2 drwxr-xr-x 3 root root 4096 2008-12-23 23:46 link -rw-r--r-- 1 root root 617 2008-12-03 02:05 .toprc -rwxr-xr-x 1 root root 574 2008-12-23 19:29 website -rw-r--r-- 1 root root 408 2008-12-23 17:20 apache.txt -rw------- 1 root root 218 2008-12-02 01:51 .recently-used.xbel -rw-r--r-- 1 root root 204 2008-12-04 02:11 .bash_profile -rw-r--r-- 1 root root 176 2006-07-13 09:06 .bashrc -rw-r--r-- 1 root root 129 2006-07-13 09:06 .tcshrc -rw------- 1 root root 106 2008-12-23 03:35 .lesshst -rw-r--r-- 1 root root 100 2006-07-13 09:06 .cshrc -rw-r--r-- 1 root root 68 2008-12-23 22:59 file -rw-r--r-- 1 root root 60 2008-12-22 20:59 file2 -rw------- 1 root root 54 2008-12-02 01:47 .xauth8ECJIu -rwxr-xr-x 1 root root 53 2008-12-22 20:58 file1 -rw-r--r-- 1 root root 53 2008-12-22 21:01 file3 -rw-r--r-- 1 root root 24 2006-07-13 09:06 .bash_logout
./.chewing: 합계 12 drwx------ 2 root root 4096 2008-12-02 01:51 . drwxr-x--- 14 root root 4096 2008-12-23 22:59 .. -rw-r--r-- 1 root root 8 2008-12-02 01:51 uhash.dat
./.dbus: 합계 12 drwx------ 3 root root 4096 2008-12-02 00:50 . drwxr-x--- 14 root root 4096 2008-12-23 22:59 .. drwx------ 2 root root 4096 2008-12-02 00:50 session-bus
./.dbus/session-bus: 합계 12 drwx------ 2 root root 4096 2008-12-02 00:50 . drwx------ 3 root root 4096 2008-12-02 00:50 .. -rw-r--r-- 1 root root 466 2008-12-02 01:51 fa160651e87369ff3307a3f64933e534-0
./.gconf: 합계 12 drwx------ 3 root root 4096 2008-12-02 01:51 . drwxr-x--- 14 root root 4096 2008-12-23 22:59 .. drwx------ 3 root root 4096 2008-12-02 01:51 apps
./.gconf/apps: 합계 12 drwx------ 3 root root 4096 2008-12-02 01:51 . drwx------ 3 root root 4096 2008-12-02 01:51 .. drwx------ 2 root root 4096 2008-12-02 01:51 sound-juicer -rw------- 1 root root 0 2008-12-02 01:51 %gconf.xml
./.gconf/apps/sound-juicer: 합계 12 drwx------ 2 root root 4096 2008-12-02 01:51 . drwx------ 3 root root 4096 2008-12-02 01:51 .. -rw------- 1 root root 421 2008-12-02 01:51 %gconf.xml
./.gconfd: 합계 8 drwx------ 2 root root 4096 2008-12-02 01:51 . drwxr-x--- 14 root root 4096 2008-12-23 22:59 .. -rwx------ 1 root root 0 2008-12-02 01:51 saved_state
./.gnome2: 합계 16 drwx------ 3 root root 4096 2008-12-02 01:01 . drwxr-x--- 14 root root 4096 2008-12-23 22:59 .. drwx------ 2 root root 4096 2008-12-02 00:50 accels -rw-r--r-- 1 root root 115 2008-12-02 01:01 system-config-network … 이하생략 |
-S옵션과 -a옵션, -R옵션을 사용하여 서브디렉토리의 내용까지 모든 파일의 용량을 기준으로 정렬한 것은 특정 디렉토리 이하의 모든 내용을 대상으로 점검하기 위한 목적으로 사용합니다.
관련자료
-
이전
-
다음