텍스트를 원하는 형식으로 조작하는데 사용된다. formatter의 약자.
바뀐게 저장은 안되고 출력으로 나온다.
fmt [-WIDTH] [OPTION]... [FILE]...
-WIDTH
: 최대 줄 너비 설정. -w
나 --width
option으로 대체 가능.
OPTION
: fmt
동작 설정
FILE
: fmt
적용 파일
기본은 줄 너비를 75로 설정해가지고 파일을 출력한다.
sycho@DESKTOP-4RPUOID:~$ cat example.txt
This page is part of the coreutils (basic file, shell and text manipulation utilities) project.
Information about the project can be found at ⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report for this manual page, see ⟨http://www.gnu.org/software/coreutils/⟩.
This page was obtained from the tarball coreutils-9.4.tar.xz fetched from ⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22.
If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which is not part of the original manual page), send a mail to man-pages@man7.org.
sycho@DESKTOP-4RPUOID:~$ fmt example.txt
This page is part of the coreutils (basic file, shell and text
manipulation utilities) project. Information about the project
can be found at ⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report for this manual page, see
⟨http://www.gnu.org/software/coreutils/⟩. This page was
obtained from the tarball coreutils-9.4.tar.xz fetched from
⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22. If you discover
any rendering problems in this HTML version of the page, or you believe
there is a better or more up-to-date source for the page, or you have
corrections or improvements to the information in this COLOPHON (which is
not part of the original manual page), send a mail to man-pages@man7.org.
-w
)sycho@DESKTOP-4RPUOID:~$ fmt -w 100 example.txt
This page is part of the coreutils (basic file, shell and text manipulation utilities) project.
Information about the project can be found at ⟨http://www.gnu.org/software/coreutils/⟩. If you
have a bug report for this manual page, see ⟨http://www.gnu.org/software/coreutils/⟩.
This page was obtained from the tarball coreutils-9.4.tar.xz fetched from
⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22. If you discover any rendering problems
in this HTML version of the page, or you believe there is a better or more up-to-date source
for the page, or you have corrections or improvements to the information in this COLOPHON
(which is not part of the original manual page), send a mail to man-pages@man7.org.
-u
)기본으로 설정되어 있다.
단어 사이의 간격은 무조건 공백 하나, 줄 사이의 간격은 무조건 공백 2개로 구별한다.
원문에서 단어 사이나 줄 사이의 공백이 뒤죽박죽이어도 이렇게 강제로 설정.
-c
)crown-margin의 약자다.
첫 두 줄을 기반으로 indentation을 정하는 이유는, 맨 처음 줄의 indentation이 문단 시작에 활용되는 indentation으로 생각하고 그 다음 줄의 indentation이 같은 내용물의 문단을 계속 진행하는데 사용된 indentation으로 생각하기 때문이다.
이 때문에 밑의 예제의 경우, 첫 문단 indentation이 공백이 많은거고 그 후 진행은 공백이 없는것으로 생각해서 출력을 했고, 두번째 문단의 경우 indentation 1개가 시작, 2개가 진행이라고 생각을 해서 출력, 마지막 문단의 경우 공백 4개가 문단의 시작이자 진행이라고 생각해서 indentation 4개를 가지고 지속적으로 출력을 하는 것이다.
이메일 형식에서 유용.
sycho@DESKTOP-4RPUOID:~$ cat example.txt
This page is part of the coreutils (basic file, shell and text manipulation utilities) project.
Information about the project can be found at ⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report for this manual page, see ⟨http://www.gnu.org/software/coreutils/⟩.
This page was obtained from the tarball coreutils-9.4.tar.xz fetched from ⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22.
If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which is not part of the original manual page), send a mail to man-pages@man7.org.
sycho@DESKTOP-4RPUOID:~$ fmt -c example.txt
This page is part of the coreutils (basic file, shell and text
manipulation utilities) project. Information about the project can be
found at ⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report for this manual page, see
⟨http://www.gnu.org/software/coreutils/⟩. This page was
obtained from the tarball coreutils-9.4.tar.xz fetched from
⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22.
If you discover any rendering problems in this HTML version of the
page, or you believe there is a better or more up-to-date source for
the page, or you have corrections or improvements to the information
in this COLOPHON (which is not part of the original manual page),
send a mail to man-pages@man7.org.
-t
)tagged-paragraph의 약자다.
각 문단에 대해, 첫줄은 타 문단과 indentation이 다르도록 설정. 문단 구분 기준은 \n
이다.
문단의 시작은 붙어있고 이후의 부분에 indentation을 부여한다.
이 때문에 각 문장이 전부 \n
으로 나뉘어져 있으면 전부 다 앞에 공백을 부여하게 된다. 그게 밑의 예제.
sycho@DESKTOP-4RPUOID:~$ cat example.txt
This page is part of the coreutils (basic file, shell and text manipulation utilities) project.
Information about the project can be found at ⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report for this manual page, see ⟨http://www.gnu.org/software/coreutils/⟩.
This page was obtained from the tarball coreutils-9.4.tar.xz fetched from ⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22.
If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which is not part of the original manual page), send a mail to man-pages@man7.org.
sycho@DESKTOP-4RPUOID:~$ fmt -t example.txt
This page is part of the coreutils (basic file, shell and text
manipulation utilities) project.
Information about the project can be found at
⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report for this manual page, see
⟨http://www.gnu.org/software/coreutils/⟩.
This page was obtained from the tarball coreutils-9.4.tar.xz fetched
from ⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22.
If you discover any rendering problems in this HTML version of the page,
or you believe there is a better or more up-to-date source for the
page, or you have corrections or improvements to the information
in this COLOPHON (which is not part of the original manual page),
send a mail to man-pages@man7.org.
sycho@DESKTOP-4RPUOID:~$ cat example.txt
This page is part of the coreutils (basic file, shell and text manipulation utilities) project. Information about the project can be found at ⟨http://www.gnu.org/software/coreutils/⟩. If you have a bug report for this manual page, see ⟨http://www.gnu.org/software/coreutils/⟩. This page was obtained from the tarball coreutils-9.4.tar.xz fetched from ⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which is not part of the original manual page), send a mail to man-pages@man7.org.
sycho@DESKTOP-4RPUOID:~$ fmt -t example.txt
This page is part of the coreutils (basic file, shell and text
manipulation utilities) project. Information about the project can
be found at ⟨http://www.gnu.org/software/coreutils/⟩. If
you have a bug report for this manual page, see
⟨http://www.gnu.org/software/coreutils/⟩. This page was
obtained from the tarball coreutils-9.4.tar.xz fetched from
⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22. If you
discover any rendering problems in this HTML version of the page,
or you believe there is a better or more up-to-date source for the
page, or you have corrections or improvements to the information
in this COLOPHON (which is not part of the original manual page),
send a mail to man-pages@man7.org.
-p
)prefix의 약자다.
특정 prefix가 있는 line만 format하도록 설정.
이때 그 line의 prefix는 format 전 제거되고, format이 된 후에 다시 앞에 붙게 된다.
특정 prefix가 있는 형식의 파일에서 용이.
sycho@DESKTOP-4RPUOID:~$ fmt -p 'T' example.txt
This page is part of the coreutils (basic file, shell and text
Tmanipulation utilities) project.
Information about the project can be found at ⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report for this manual page, see ⟨http://www.gnu.org/software/coreutils/⟩.
This page was obtained from the tarball coreutils-9.4.tar.xz fetched
Tfrom ⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22.
If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which is not part of the original manual page), send a mail to man-pages@man7.org.
-s
)split-only의 약자다.
기본 fmt
처럼 줄이 지정된 너비를 넘기면 쪼갠다. 다만, 기본 fmt
는 새로운 줄도 그 뒤에 이어서 계속 작성을 하는데 이 option을 설정하면 새로운 줄은 또 새로운 줄에서 시작하도록 설정한다.
sycho@DESKTOP-4RPUOID:~$ fmt -s example.txt
This page is part of the coreutils (basic file, shell and text
manipulation utilities) project.
Information about the project can be found at
⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report for this manual page, see
⟨http://www.gnu.org/software/coreutils/⟩.
This page was obtained from the tarball coreutils-9.4.tar.xz fetched
from ⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2023-12-22.
If you discover any rendering problems in this HTML version of the page,
or you believe there is a better or more up-to-date source for the page,
or you have corrections or improvements to the information in this
COLOPHON (which is not part of the original manual page), send a mail
to man-pages@man7.org.
-g
)goal의 약자다.
정해진 maximum width (-w
로 설정, 기본은 75)가 한계라면, 이것은 가급적 fmt
가 맞추려고 하는 width라고 생각하면 된다.
기본값은 -w
의 93%에 해당하는 값이다.
sycho@DESKTOP-4RPUOID:~$ fmt -g 30 example.txt
This page is part of the
coreutils (basic file,
shell and text manipulation
utilities) project. Information
about the project can be found at
⟨http://www.gnu.org/software/coreutils/⟩.
If you have a bug report
for this manual page, see
⟨http://www.gnu.org/software/coreutils/⟩.
This page was obtained from the tarball
coreutils-9.4.tar.xz fetched from
⟨http://ftp.gnu.org/gnu/coreutils/⟩
on 2023-12-22. If you discover
any rendering problems in this
HTML version of the page, or
you believe there is a better or
more up-to-date source for the
page, or you have corrections or
improvements to the information
in this COLOPHON (which is not
part of the original manual page),
send a mail to man-pages@man7.org.