·터미널 명령어

less

파일·디렉터리

쓰는 꼴

less [file]

파일을 통째로 읽지 않고 한 화면씩 보여줍니다. /로 찾고 q로 나오는데, more처럼 끝에서 저절로 닫히지 않습니다.

자주 쓰는 옵션

옵션
-NShow line numbers
-SChop long lines instead of wrapping them
-iIgnore case while searching unless the pattern has capitals
-RPass color escape codes through as colors
+FStart in follow mode, like tail -f
-XLeave the output on screen after quitting
/wordSearch forward; n repeats it, q quits less

예시

less +F /var/log/syslog

Follows the log; Ctrl-C stops following and lets you scroll.

less -S wide.csv

Keeps each record on one row so columns stay aligned.

git log | less -R

Pages colored output with the colors kept.

옮기고 지우고 찾는 것들. 되돌릴 수 없는 명령이 섞여 있어 -i를 붙이는 습관이 손을 구합니다.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. less은 무엇을 하나요?

파일을 통째로 읽지 않고 한 화면씩 보여줍니다. /로 찾고 q로 나오는데, more처럼 끝에서 저절로 닫히지 않습니다.

Q. 어떻게 치나요?

less [file] — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 7개입니다. 전체 목록은 man less에 있습니다. 이 명령은 파일·디렉터리 갈래입니다.

같이 보는 명령

man 페이지: man less