C.W.K.
Stream
Lesson 03 of 12 · published

ls 의 진짜 flag 들

~12 min · ls, flags, macos

Level 0창 구경꾼
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

-lah 너머

long-all-human 콤보는 알지. find 안 꺼내고 ls 하나로 더 할 수 있는 것들 보자.

정렬

  • -t — mtime, 최신 먼저
  • -tr — 최신을 아래 로. tail 과 궁합 최고: ls -tr | tail = 가장 최근에 바뀐 거.
  • -S — 크기 큰 거 먼저. ls -lhS | head 가 '디스크 누가 잡아먹어?' one-liner.
  • -X (GNU) — 확장자 정렬

표시

  • -1 — 한 줄에 하나. pipe 에 좋음.
  • -F — 디렉터리에 /, 실행 파일에 *, symlink 에 @.
  • -d — 디렉터리 자체만, 내용 안 펼침. ls -d */ = 서브디렉터리 이름만.
  • -i — inode 번호 (hard link 추적용).
  • -G (BSD) / --color=auto (GNU) — 색.

숨김 vs almost-all

-a. (현재) 와 .. (부모) 도 같이 보여. 보통은 -A 가 더 쓸만 해 — 모든 dotfile 인데 그 둘은 빼고.

시간 정밀도

기본 ls -l 은 옛 파일은 연도, 최근은 시간. GNU 면 ls -l --time-style=full-iso 로 ISO-8601. macOS BSD ls 는 ls -lT 가 풀 timestamp.

Code

디스크 누가 잡아먹어?·bash
ls -lhS ~/Downloads | head
# Largest directories
du -sh * 2>/dev/null | sort -h | tail
서브디렉터리 이름만·bash
ls -d */
# With dotfile dirs included
ls -d .*/ */ 2>/dev/null

External links

Exercise

홈에서 ls -tr | tail, ls -lhS | head, ls -d */, ls -lA 차례로 실행. 각각이 다른 질문에 답하는 거 느껴봐. 합치기: ls -lhSr ~/Downloads | tail — 가장 큰 다운로드가 맨 아래.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.