more 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-more
핵심 정리
- 파일 내용을 한 화면씩 보여 줍니다. 화면마다 멈추고 맨 아래에
More를 표시합니다. - 스페이스바는 다음 화면, Enter는 한 줄 더,
b는 뒤로,/패턴은 앞으로 찾기,?패턴은 뒤로 찾기,q는 끝내기입니다. - 하위 명령 앞에 숫자 K를 붙여 횟수나 줄 번호를 줄 수 있습니다(
10j,100g,50%). -p 하위명령으로 시작 위치를 정합니다(-p G는 마지막 화면부터,-p /foo는foo가 처음 나오는 줄부터).- 창 크기는 기본으로 터미널 줄 수보다 2줄 적고,
-n이나LINES변수로 바꿉니다.MORE변수에 늘 쓰는 플래그를 넣어 둘 수 있습니다. - 표준 출력이 터미널이 아니면
cat처럼 동작합니다. AIX 5.3과 6.1 문서의 내용이 같습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (두 버전 내용 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 3, 6.1 Volume 3 |
| 파일 | /usr/share/lib/terminfo(터미널 정보) |
| 관련 명령어 | pg, cat, ksh, ctags, vi |
목적
파일 내용을 한 화면씩 표시합니다.
영어 원문
Displays file contents one screen at a time.
구문
more [ -c ] [ -d ] [ -e ] [ -H ] [ -i ] [ -l ] [ -N ] [ -s ] [ -u ] [ -v ] [ -z ] [ -n Number ]
[ -p Subcommand ] [ -t Tagstring ] [ -W Option ] [ -x Tabs ] [ File ... ]
설명
more 명령은 파일을 읽어 한 화면씩 표시합니다. 화면마다 멈추고 화면 맨 아래에 More라는 말을 표시합니다. 이때 Enter(캐리지 리턴)를 누르면 한 줄을 더 보여 주고, 스페이스바를 누르면 다음 한 화면을 보여 줍니다.
참고: 어떤 터미널 기종에서는 스크롤하는 대신 화면을 지웁니다.
읽을 파일 이름을 주는 대신, 긴 디렉터리 목록 같은 표준 출력을 재지정하거나 파이프로 more 명령에 넘길 수도 있습니다. 파이프가 아닌 파일에서 읽을 때는 안내 문구에 %(퍼센트 기호)를 붙여, 파일을 얼마나 읽었는지(줄이 아니라 문자 기준) 보여 줍니다.
more 명령은 출력이 끊기지 않도록 터미널을 NOECHO 모드로 둡니다. 그래서 /와 ! 하위 명령을 빼고는 입력한 명령이 보통 화면에 나타나지 않습니다. 표준 출력이 터미널이 아니면 cat 명령처럼 동작하되, 파일이 여러 개면 파일마다 앞에 머리글을 출력합니다.
환경 변수
환경 변수는 more 명령의 동작에 영향을 줍니다. 일부 환경 특성은 /etc/environment 파일과 .ksh, .csh, .profile 같은 시스템 프로필 파일에서 정할 수 있습니다.
| 변수 | 쓰임 |
|---|---|
TERM |
터미널 특성을 정합니다. 이 변수가 NULL이거나 없으면 기본 터미널 형식을 씁니다. 터미널 특성 정의는 /usr/share/lib/terminfo 디렉터리에 있습니다. |
LINES |
기본 창 크기를 정합니다. 기본 창 크기는 시스템 터미널이 표시할 수 있는 줄 수보다 2줄 적습니다. 실행할 때마다 -n 플래그로 쉽게 바꿀 수도 있습니다. |
MORE |
시스템을 시작할 때마다 늘 쓰는 설정으로 more 명령을 맞춥니다. more 명령의 플래그를 값으로 받습니다. |
영어 원문
The more command reads files and displays the text one screen at a time. The command pauses after each screen and prints the word More at the bottom of the screen. If you then press a carriage return, the more command displays an additional line. If you press the space bar, the more command displays another full screen of text.
Note: On some terminal models, the more command clears the screen, instead of scrolling.
Instead of naming files to read, you can either redirect or pipe standard output, such as a long directory listing, to the more command. The command adds a % (percent sign) to its prompt when reading from a file rather than a pipe. This provides the percentage of the file (in characters, not lines) that the more command has read.
The more command sets the terminal to NOECHO mode so the output can be continuous. With the exception of the / and ! subcommands, commands that are typed do not normally show up on the terminal. If the standard output is not a terminal, the more command will act just like the cat command, except that a header will be printed before each file in a series.
Environment Variables
Environment variables affect the way the more command works. You can set some environment characteristics in the /etc/environment file and system profile files, such as the .ksh, .csh, and .profile files.
The more command uses the TERM variable to determine terminal characteristics. If this variable is NULL or not set, the command uses the default terminal type. The /usr/share/lib/terminfo directory contains definitions for terminal characteristics.
By default, the more command window size is 2 lines less than what the system terminal is capable of. The command sets the default window size based on the LINES variable. Also, you can easily adjust the window size for each run of the command by adding the -n flag.
Use the MORE variable to customize the more command with your preferred configuration each time the system starts. This variable accepts more command flags.
플래그
| 플래그 | 설명 |
|---|---|
-c |
화면을 스크롤하지 않게 해서, more가 화면에 쓰는 동안 글을 읽기 쉽게 합니다. 터미널이 줄 끝까지 지우지 못하면 -c를 무시합니다. |
-d |
화면 맨 아래 More 안내 뒤에, 계속하기·끝내기·도움말 키를 알려 주는 메시지를 붙입니다. 알 수 없는 명령을 쓰면 터미널 벨을 울리는 대신 오류 메시지를 표시합니다. 익숙하지 않은 사용자에게 좋습니다. |
-e |
마지막 파일의 마지막 줄을 표시한 뒤 자동으로 끝냅니다. |
-H |
검색 패턴 강조 기능을 기본으로 끕니다. |
-i |
대소문자를 구분하지 않고 패턴을 찾습니다. |
-l |
입력에서 쪽 나눔을 만나도 멈추지 않습니다. -l이 없으면 ^L(Ctrl-L) 문자가 든 줄 뒤에 멈춰 명령을 받습니다. 또 파일이 폼 피드로 시작하면 파일을 출력하기 전에 화면을 지웁니다. |
-N |
줄 번호 매기기를 끕니다. 기본인 줄 번호 표시는 아주 큰 입력 파일에서 more를 느리게 할 수 있습니다. 줄 번호 기능은 = 하위 명령에 줄 번호를 표시하고, 편집기(vi일 때)에 줄 번호를 넘깁니다. |
-n Number |
창에 표시할 줄 수를 정합니다. -n이 없으면 터미널 줄 수보다 2줄 적은 값이 기본입니다. 예를 들어 24줄 터미널이면 22줄입니다. -n 옵션은 환경에서 얻은 값보다 우선합니다. |
-p Subcommand |
File 피연산자마다 more를 시작하면서 지정한 하위 명령을 실행합니다(아래 설명). |
-s |
출력에서 연속된 빈 줄 여러 개를 하나로 줄입니다. nroff 명령의 출력을 볼 때 특히 좋습니다. |
-t Tagstring |
지정한 태그가 든 파일 부분을 표시합니다. ctags 명령으로 만든 태그가 있는 파일에서만 동작합니다. |
-u |
백스페이스 문자를 인쇄할 수 있는 제어 문자(^H로 표시)로 다루지 않게 해서, 원본 파일의 밑줄 친 부분에 대한 백스페이스·밑줄·반전 표시를 하지 않습니다. 또 줄 끝에 캐리지 리턴 문자가 있으면 그것을 알아보게 합니다. |
-v |
인쇄할 수 없는 문자를 그림 문자로 바꿔 보여 주지 않습니다. -v가 없으면 탭, 백스페이스, 리턴을 빼고 ASCII가 아닌 문자와 대부분의 제어 문자를 바꿔 보여 줍니다. 예를 들어 Ctrl-x는 ^X로, ASCII가 아닌 문자 x는 M-x로 표시합니다. |
-W Option |
지정한 Option을 확장 기능으로 넘깁니다(아래 설명). |
-x Tabs |
탭 위치를 Tabs로 정합니다. 기본은 8칸입니다. |
-z |
탭, 백스페이스, 리턴 제어 문자를 보이게 표시합니다. 백스페이스는 ^H, 리턴은 ^M, 탭은 ^I로 표시합니다. |
-p의 쓰임
예를 들어 more -p 50j text1 text2는 text1 파일을 50번째 줄부터 보여 주고, 첫 파일을 다 보면 text2도 같은 방식으로 보여 줍니다. 하위 명령은 아래 "하위 명령"을 봅니다.
줄 번호나 정규 표현식 검색 같은 위치 지정 명령이면, 중간 줄을 쓰지 않고 그 명령의 최종 결과를 현재 위치로 정합니다. 예를 들어 다음 두 명령은 기능이 같으며, 둘 다 1000번째 줄을 현재 위치로 두고 시작합니다. 파일을 보는 중에 j를 입력했을 때 출력되며 화면 위로 지나갔을 줄들은 건너뜁니다.
more -p 1000j filename
more -p 1000G filename
위치 지정 명령이 실패하면 파일의 첫 줄이 현재 위치가 됩니다.
-W의 Option
| Option | 뜻 |
|---|---|
notite |
파일을 표시하기 전에 터미널 초기화 문자열(termcap의 ti나 terminfo의 smcup)을 보내지 않고, 끝내기 전에 해제 문자열(termcap의 te나 terminfo의 rmcup)도 보내지 않습니다. |
tite |
초기화 문자열과 해제 문자열을 보냅니다. 기본값입니다. |
이 옵션은 위 문자열을 보낼지를 정합니다. 어떤 터미널(일부 xterm 등)에서는 이 문자열 때문에 다른 화면으로 바뀌고, 그러면 보던 파일 내용이 화면에서 지워집니다.
하위 명령
more 명령은 멈춰 있을 때, 그리고 -p 플래그의 매개변수로 하위 명령을 받습니다. 많은 하위 명령이 선택 정수 K(여기서는 K로 표시)를 받는데, 하위 명령 앞에 띄우지 않고 씁니다. 멈춰 있는 동안에는 Enter 키를 누르지 않아도 하위 명령을 바로 처리합니다.
| 하위 명령 | 설명 |
|---|---|
h |
more 하위 명령을 설명하는 도움말 화면을 표시합니다. |
v |
vi 편집기를 시작해 현재 파일을 현재 줄에서 편집합니다. |
r, ^L |
화면을 다시 그립니다. |
R |
화면을 다시 그리고 버퍼에 쌓인 입력을 지웁니다. |
[K](스페이스바) |
K줄 앞으로 갑니다. K가 없으면 다음 한 화면을 표시합니다. [K]f, [K]^F, [K]z와 같습니다. |
[K]f, [K]^F, [K]z |
K줄 앞으로 갑니다. K가 없으면 한 화면 앞으로 갑니다. |
[K]b, [K]^B |
K줄 뒤로 갑니다. K가 없으면 한 화면 뒤로 갑니다. |
[K]d, [K]^D |
K줄 앞으로 갑니다. K가 없으면 반 화면 앞으로 갑니다. K를 주면 이 세션 동안 d와 u의 스크롤 크기를 K줄로 정합니다. |
[K]u, [K]^U |
K줄 뒤로 갑니다. K가 없으면 반 화면 뒤로 갑니다. K를 주면 이 세션 동안 d와 u의 스크롤 크기를 K줄로 정합니다. |
[K]j, [K](Enter), [K]^E |
K줄 앞으로 갑니다. K가 없으면 한 줄 앞으로 갑니다. |
[K]k, [K]^Y |
K줄 뒤로 갑니다. K가 없으면 한 줄 뒤로 갑니다. |
[K]g |
파일의 처음으로 갑니다. K로 줄 번호를 주면 그 줄로 갑니다. 기본은 1번 줄입니다. |
[K]G |
파일의 마지막 줄로 갑니다. K로 줄 번호를 주면 그 줄로 갑니다. |
[K]p, [K]% |
전체 파일의 K퍼센트 지점으로 갑니다. 기본은 1퍼센트, 곧 파일의 첫 줄입니다. |
ma-z |
현재 위치에 지정한 글자(a~z)로 표시를 해 둡니다. |
'a-z |
(작은따옴표) 지정한 글자로 표시해 둔 위치로 갑니다. |
'' |
(작은따옴표 두 개) 마지막으로 크게(한 쪽 넘게) 이동하기 전의 위치로 돌아갑니다. 그런 이동이 없었으면 파일의 처음으로 갑니다. |
[K]/pattern |
(슬래시) 현재 위치에서 앞으로, 지정한 패턴이 K번째로 나오는 곳을 찾습니다. 기본은 첫 번째입니다. |
[K]/!pattern |
(슬래시, 느낌표) 현재 위치에서 앞으로, 패턴이 들어 있지 않은 줄이 K번째로 나오는 곳을 찾습니다. |
[K]?pattern |
(물음표) 현재 위치에서 뒤로, 지정한 패턴이 K번째로 나오는 곳을 찾습니다. |
[K]?!pattern |
(물음표, 느낌표) 현재 위치에서 뒤로, 패턴이 들어 있지 않은 줄이 K번째로 나오는 곳을 찾습니다. |
[K]n |
마지막 검색을 되풀이합니다(검색에 !가 있었으면 패턴이 없는 줄을 찾습니다). 기본은 첫 번째입니다. |
:a |
more 명령줄에 지정한 파일 목록을 보여 줍니다. |
:f, ^G, = |
현재 파일의 정보(파일 이름, 파일 목록에서의 순서, 현재 줄 번호, 파일 안의 현재 위치(퍼센트), 현재 바이트 번호와 표시할 전체 바이트)를 표시합니다. |
:e[File], E[File] |
지정한 파일을 봅니다. more 명령줄에 지정한 파일이어야 합니다. |
[K]:n, [K]N |
다음 파일을 봅니다. K를 주면 명령줄 파일 목록에서 K번째 뒤의 파일을 봅니다. |
[K]:p, [K]P |
이전 파일을 봅니다. K를 주면 명령줄 파일 목록에서 K번째 앞의 파일을 봅니다. |
:t Tagstring |
지정한 태그가 든 파일 부분을 표시합니다. ctags로 만든 태그가 있는 파일에서만 동작합니다. -t 플래그의 대화형 판입니다. |
:q, q, Q |
more 명령을 끝냅니다. |
:!command, !command |
새 셸에서 지정한 명령을 실행합니다. |
H |
검색 패턴 강조 기능을 켜고 끕니다. |
영어 원문
-c— Prevents the screen from scrolling, which makes text easier to read as the more command writes to the screen. The system ignores the-cflag if the terminal cannot clear to the end of a line.-d— Prints a message, appended to theMoreprompt at the bottom of the screen, about which keys continue, quit, and provide help for the more command. Displays error messages rather than ringing the terminal bell if an unrecognized command is used. This is helpful for inexperienced users.-e— Exits automatically after displaying the last line of the last file.-H— Disables the search pattern highlighting feature by default.-i— Searches for patterns without considering uppercase and lowercase.-l— Pauses after detecting a page break in the input. If the-lflag is not used, the more command pauses to accept commands after any line containing a^L(CTRL-L) character. Also, if a file begins with a FORMFEED, the screen is cleared before the file is printed.-N— Suppresses line numbering. The default display, with line numbers, can slow the more command's performance on very large input files. The line numbering feature displays the line number in the = subcommand and passes the line number to the editor (if it is the vi editor).-nNumber — Configures the more command to display the specified number of lines in the window. Without the-nflag, the more command defaults to two lines less than what the terminal is capable of. For example, on a 24-line terminal, the default is 22 lines. The-noption overrides any values obtained from the environment.-pSubcommand — Starts the more command and specified subcommand for each File operand. For example, more -p 50j text1 text2 displays the text1 file at the fiftieth line; then does the same for the text2 file when you finish the first. See "Subcommands" for descriptions of more subcommands. If the command is a positioning command, such as a line number or a regular expression search, set the current position to represent the final results of the command, without writing any intermediate lines of the file. For example, the two commands:more -p 1000j filename more -p 1000G filenameare functionally the same and will start the display with the current position at line 1000, passing the lines that j would write and would scroll off the screen if it had been issued during the file examination. If the positioning command is unsuccessful, the first line in the file will be the current position.-s— Reduces multiple blank lines in the output to only one blank line. The-sflag is particularly helpful in viewing output from the nroff command.-tTagstring — Displays the portion of the file that contains the specified tag. This flag works only on files containing tags created with the ctags command.-u— Prevents the more command from treating a backspace character as a printable control character (displayed as a ^H (CTRL-H)), suppressing backspacing, underlining, or creating reverse video text for underlined information in a source file. The-uflag also forces the more command to recognize a carriage-return character, if it exists, at the end of a line.-v— Suppresses the graphical translation of nonprinting characters. Without the-vflag, the more command graphically interprets all non-ASCII and most control characters, except Tab, Backspace, and Return. For example, if you do not use the-vflag, the more command displays the non-ASCII characters Ctrl-x as^Xand x asM-x.-WOption — Provides the specified Option to the more command as an extension: notite Prevents the more command from sending the terminal initialization string (either the ti termcap or the smcup terminfo capability) before displaying the file. This option also prevents the more command from sending the terminal de-initialization string (either the te termcap or the rmcup terminfo capability) before exiting. tite Causes the more command to send the initialization and de-initialization strings. This is the default. These options control whether the more command sends the initialization strings described, which, for certain terminals (such as some xterms), cause the more command to switch to an alternative screen. The effect of switching screens is to erase the display of the file you were viewing.-xTabs — Sets tab stops at the specified Tabs position. The default tab setting is 8 columns.-z— Graphically displays the Tab, Backspace, and Return control characters. With the-zflag, the more command translates the Backspace character as^H, Return as^M, and Tab as^I.- Subcommands
The more command accepts subcommands when the command pauses and as parameters for the -p flag. Many subcommands take an optional integer, symbolized here by K, which you must enter before the subcommand, with no space between. The more command, in the paused state, processes subcommands immediately and does not require you to press the Enter key.
The more command uses the following subcommands:
- h — Displays a help screen that describes the more subcommands.
- v — Starts the vi editor, editing the current file in the current line.
- r or ^L — Refreshes the display.
- R — Refreshes the display and removes buffered input.
- K — Moves forward K lines when you press the spacebar. If you do not give a value for K, pressing the spacebar displays the next full screen by default. This spacebar subcommand is the same as [K]f or [K]^F or [K]z.
- [K]f or [K]^F or [K]z — Moves forward K lines, or one full screen if you do not give a value for K.
- [K]b or [K]^B — Moves backward K lines, or one full screen if you do not give a value for K.
- [K]d or [K]^D — Moves forward K lines, or half a screen if you do not give a value for K. If you give a value for K, the more command sets the d and u scroll size to K lines for the session.
- [K]u or [K]^U — Moves backward K lines, or half a screen if you do not give a value for K. If you give a value for K, the more command sets the d and u scroll size to K lines for the session.
- [K]j or K or [K]^E — Moves forward K lines, or one line if you do not give a value for K.
- [K]k or [K]^Y — Moves backward K lines, or one line if you do not give a value for K.
- [K]g — Moves to the beginning of the file, unless you give a line number for K. The default for K is line number 1.
- [K]G — Moves to the last line in the file, unless you give a line number for K. The default for K is the last line in the file.
- [K]p or [K]% — Moves to the point in the file that is K percent of the total file. The default for K is one percent, or the first line in the file.
- ma-z — Marks the current position in the file with the specified letter.
- 'a-z — (Single quote) Moves to the position marked with the specified letter.
- '' — (Two single quotes) Returns to the position from which the last large movement (moving more than a page) command was run. If no such movements have been made, returns to the beginning of the file.
- [K]/pattern — (Slash) Searches forward, from the current position, for the specified occurrence of the specified pattern of characters. The default value for K is the first occurrence.
- [K]/!pattern — (Slash, exclamation mark) Searches forward, from the current position, for the specified occurrence of a line that does not contain the specified pattern of characters. The default value for K is the first occurrence.
- [K]?pattern — (Question mark) Searches backward, from the current position, for the specified occurrence of the specified pattern of characters. The default value for K is the first occurrence.
- [K]?!pattern — (Question mark, exclamation mark) Searches backward, from the current position, for the specified occurrence of a line that does not contain the specified pattern of characters. The default value for K is the first occurrence.
- [K]n — Repeats the last search, specifying an occurrence of the pattern (or an occurrence not containing the pattern if the search subcommand included !). The default value for K is the first occurrence.
- :a — Lists the file or files you named in the more command line.
- :f or ^G or = — Displays information about the current file: • file name • order of the file in the list of files • current line number • current position in the file, given as a percentage • current byte number and total bytes to display.
- :e[File] or E[File] — Examines the specified file, provided you named it in the more command line.
- [K]:n or [K]N — Examines either the next file (if you do not give a value for K) or the file K number of positions forward in the list of files you named in the more command line.
- [K]:p or [K]P — Examines either the previous file (if you do not give a value for K) or the file K number of positions backward in the list of files you named in the more command line.
- :t Tagstring — Displays the portion of the file that contains the specified tag. This subcommand works only on files containing tags created with the ctags command. The :t subcommand is the interactive version of the
-tflag. - :q or q or Q — Exits the more command.
- :!command or !command — Starts the specified command in a new shell.
- H — Toggles the search pattern highlighting feature on or off.
종료 상태
| 값 | 뜻 |
|---|---|
| 0 | 잘 끝났습니다. |
| 0보다 큼 | 오류가 났습니다. |
영어 원문
This command returns the following exit values:
- 0 — Successful completion.
>0— An error occurred.
예제
myfile파일을 봅니다.
more myfile
- 명령의 출력을 한 화면씩 봅니다.
ls -l | more
- 파일마다 마지막 화면부터 봅니다.
more -p G file1 file2
- 파일마다 100번째 줄을 현재 위치로 두고 봅니다. 보통
more화면에서 현재 위치는 화면의 셋째 줄이므로, 이 예에서 화면의 첫 줄은 파일의 98번째 줄입니다.
more -p 100 file1 file2
- 파일마다
foo문자열이 처음 나오는 줄부터 봅니다. 그 줄이 현재 위치, 곧 화면의 셋째 줄에 표시됩니다.
more -p /foo file1 file2
영어 원문
- To view a file named
myfile, enter:
more myfile
- To view output from the nroff command, enter:
ls -l | more
- To view each file starting at its last screen, enter:
more -p G file1 file2
- To view each file with the 100th line at the current position, enter:
more -p 100 file1 file2
Typically, the current position in a more command display is the third line on the screen. In this example, the first line on the screen is the 98th line in the file.
- To view each file starting with the first line that contains the
foostring, enter:
more -p /foo file1 file2
The more command displays the line in the current position, the third line on the screen.
파일
| 파일 | 설명 |
|---|---|
/usr/share/lib/terminfo |
터미널 정보 데이터베이스입니다. |
관련 명령어: ksh
영어 원문
- /usr/share/lib/terminfo — Indicates the terminal information database.
Related reference:
- ksh Command
Related information:
- environment command
- User environment
- Understanding Locale Environment Variables
리눅스(GNU)와 다른 점
| 항목 | AIX 5.3·6.1 | 리눅스 more(util-linux) |
|---|---|---|
뒤로 가기·표시·-p 위치 지정 |
b, ma-z, -p 하위명령을 지원(POSIX more) |
b는 되지만 표시와 -p 같은 위치 지정은 없음(+줄번호, +/패턴을 씀) |
-p |
시작할 때 하위 명령 실행 | 화면을 스크롤하지 않고 지운 뒤 표시 |
-N·-H·-W |
줄 번호 끄기, 강조 끄기, 터미널 초기화 문자열 제어 | 없음 |
리눅스에서는 이런 기능이 필요할 때 보통 less를 씁니다.