오경석의 개발노트

Linux_tree 본문

소프트웨어, 운영체제/Linux

Linux_tree

OHSAYU 2024. 1. 20. 20:38

tree : 파일과 디렉터리를 트리 형태로 출력🌳

■ 설치

yum -y install tree # 리눅스 내장 명령어가 아니므로 초기에 설치 필요

■ 구조

tree [OPTION] 디렉터리경로

■ 옵션

● -d : 디렉터리만 표시

● -f : 파일의 전체 경로 표시

● -df : 전체 경로까지 표함된 서브디렉터리 표시

● -a : 숨겨진 파일까지 표시

● -L : 표시할 디렉터리 단계 표시(ex. tree -L 3)

● -u : 사용자 이름(UID) 표시

● -g : 그룹 이름(GID) 표시

● -p : 파일 권한 표시

● -P : 와일드카드 패턴에 맞는 파일 표시

● -I : 특정 디렉터리 제외(대문자 i)

● -h :  파일 및 디렉터리 용량 사람이 읽기 쉽게 단위로 표시 

● -s :  파일 및 디렉터리 용량 byte 표시

● -D : 마지막으로 수정한 시각 표시 

● --prune : 빈 디렉터리는 결과에서 제외

● --du : 각 서브디렉터리의 크기를 그에 속한 모든 파일과 서브디렉터리를 합산해 표시

등등

■ 예시

- 옵션을 사용하지 않으면 현재 위치에 대한 폴더 및 파일 구조 확인 및 하단에 폴더/파일 수 출력
[root@TEST test]# tree 
.
├── sample
│   └── fds.txt
└── sample2

1 directory, 2 files
[root@TEST test]# tree -d
.
└── sample

1 directory
[root@TEST test]# tree -f
.
├── ./sample
│   └── ./sample/fds.txt
└── ./sample2

1 directory, 2 files
[root@TEST test]# tree -df
.
└── ./sample

1 directory
[root@TEST test]# tree -L 1
.
├── sample
└── sample2

1 directory, 1 file
[root@TEST test]# tree -fL 1
.
├── ./sample
└── ./sample2

1 directory, 1 file
[root@TEST test]# tree -fI 'sample'
.
└── ./sample2

0 directories, 1 file
[root@TEST test]# tree -p
.
├── [drwxr-xr-x]  sample
│   └── [-rw-r--r--]  fds.txt
└── [-rw-r--r--]  sample2

1 directory, 2 files
[root@TEST test]# tree -pug
.
├── [drwxr-xr-x root     user2   ]  sample
│   └── [-rw-r--r-- root     user1   ]  fds.txt
└── [-rw-r--r-- root     user2   ]  sample2

1 directory, 2 files
[root@TEST test]# tree -P *t*
.
└── sample
    └── fds.txt

1 directory, 1 file
[root@TEST test]# tree -D
.
├── [Jan 15  4:00]  sample
│   └── [Jan 15  4:00]  fds.txt
└── [Jan 15  4:36]  sample2

1 directory, 2 files

 

 

출처 : https://velog.io/@eunjeong/TIL-CentOS-tree-%EB%AA%85%EB%A0%B9%EC%96%B4

 

[TIL] CentOS tree 명령어

파일과 디렉토리를 트리 형태로 출력\-d : 디렉토리만 표시\-f : 파일의 전체 경로 표시\-df : 전체경로까지 포함된 서브디렉토리 표시\-a : 숨겨진 파일까지 표시\-L : 표시할 디렉터리 단계 표시\-p :

velog.io

출처 : https://antilibrary.org/2364

 

초보자를 위한 리눅스 tree 명령어 사용법 Linux ‘tree Command’ Usage Examples for Beginners

Photo by Johannes Plenio from Pexels tree 는 디렉토리를 리스팅하거나 컨텐츠 내용을 볼 때 사용할 수 있는 간단한 명령어이다. 디렉토리 경로와 서브디렉토리내의 파일, 그리고 서브디렉토리와 파일의

antilibrary.org

 

Comments