Find files and directory in Linux
리눅스 상에서 파일, 디렉토리 찾기
du (Disk Usage)
Check linux directory usage
디스크 사용량 체크 명령어
1 | # du [OPTIONS] [FILE] | cs |
1 2 3 4 5 6 7 | to check directory’s usage # du -hs DIR to check files and directory’s usage in current directory # du -hs * to limit recursive directory depth # du --max-depth=1 | cs |
-h |
--human-readable |
-s |
--summarize: display only a total for each argument |
-x |
--one-file-system: skip directories on different file system |
grep
Print matching line
패턴과 매치되는 파일 또는 디렉터리 출력
1 2 3 | # grep [OPTIONS] PATTERN [FILE] egrep == grep -E | cs |
-E |
--extended-regexp |
-v |
--invert-match |
-c |
count lines |
-i |
case insensitive |
-n |
set line number |
-l |
print matching file name |
-w |
print line with perfect match |
sort
Sorting list of files
출력하는 내용을 옵션에 따라 정렬해주는 명령
-r |
--reverse |
-h |
--human-numeric-sort: compare according to general numerical value |
head
Print top to N lines
출력 시 위에서 N 번째 줄 까지 출력
1 | # head -n 20 | cs |
xarg
Make a command line on standard input and execute them.
표준 입력으로부터 명령을 받아 실행하는 명령으로, ls 명령과 조합하여 각 ls 명령 결과 줄에 따른 명령을 다시 실행할 수 있다.
1 | # xarg -i [replace-str] | cs |
-I or i |
replace with replace-str |
Sample
du -h --max-depth=1 * |sort -hr |head
ls | egrep -v "cache|proc" | xargs -i du -sh {} |sort -h
'System Engineering > Linux' 카테고리의 다른 글
Bash: sed (0) | 2019.05.07 |
---|---|
Tools: ab (0) | 2018.08.30 |
Check and recover disk badblocks (0) | 2018.08.16 |
Apache: Security settings (0) | 2018.08.03 |
Apache: httpd set-up (0) | 2018.08.03 |