아래와 같은 ls의 결과의 처음 몇 줄 또는 마지막 몇 줄을 얻기 위해 head와 tail을 사용해보자.
# ls -alp
total 56
drwxr-xr-x 10 root root 4096 Jan 1 1970 ./
drwxrwxr-x 24 1001 1001 4096 Jan 1 1970 ../
drwxr-xr-x 2 root root 20480 Jan 1 1970 bin/
drwxr-xr-x 2 root root 4096 Apr 10 2014 games/
drwxr-xr-x 51 root root 4096 Jan 1 1970 include/
drwxr-xr-x 37 root root 4096 Jan 1 1970 lib/
drwxr-xr-x 10 root root 4096 Jan 1 1970 local/
drwxr-xr-x 2 root root 4096 Jan 1 1970 sbin/
drwxr-xr-x 78 root root 4096 Jan 1 1970 share/
drwxr-xr-x 2 root root 4096 Apr 10 2014 src/
처음의 몇 줄
# ls -alp | head -1
total 56
# ls -alp | head -2
total 56
drwxr-xr-x 10 root root 4096 Jan 1 1970 ./
마지막의 몇 줄
# ls -alp | tail -1
drwxr-xr-x 2 root root 4096 Apr 10 2014 src/
# ls -alp | tail -2
drwxr-xr-x 78 root root 4096 Jan 1 1970 share/
drwxr-xr-x 2 root root 4096 Apr 10 2014 src/
'놀기 > Linux' 카테고리의 다른 글
SIOCSIFHWADDR: Cannot assign requested address (0) | 2022.12.26 |
---|---|
Ubuntu 20.04 - 터미널 벨소리 끄기 (0) | 2022.11.19 |
Samba 설정하기 (0) | 2022.01.14 |
Static IP 설정 - Ubuntu 20.04 (0) | 2022.01.14 |
git 접속을 위한 ssh key 생성 (0) | 2022.01.14 |
댓글