Linux fmt command details how to use Linux fmt command

Source: Internet
Author: User

The fmt command reads the content from the specified file, reorchestrates it according to the specified format, and then outputs it to the standard output device. If the specified file name is "-", The fmt command reads data from the standard input device.

Syntax

Fmt [-cstu] [-p <column start string>] [-w <number of characters in each column>] [-- help] [-- version] [file...]

Parameter description:

  • -C or -- crown-margin: scale down the first two columns of each segment.
  • -P <column start string> or-prefix = <column start string> only merges columns containing the specified string, which is usually used in program language annotations.
  • -S or -- split-only splits columns whose words exceed the number of characters in each column, but does not merge columns whose words are less than the number of characters in each column.
  • -T or -- tagged-paragraph: the first two columns of each column are reduced, but the 1st and 2nd columns are in different formats.
  • -U or -- uniform-spacing each character is separated by a space character, and each sentence is separated by two spaces.
  • -W <number of characters in each column> or -- width = <number of characters in each column> or-<number of characters in each column> sets the maximum number of characters in each column.
  • -- Help online help.
  • -- Version: displays the version information.

Instance

Rearrange the specified file. For example, if the file testfile contains five lines of text, you can run the following command to rearrange the file format:

Fmt testfile

The output result is as follows:

$ Fmt testfile # rearrange the testfile

Hello Linux! Linux is a free Unix-type operating system. This is

Linux testfile! Linux

Repeat the file testfile into 85 characters and output it on the standard output device. The Command should be:

Fmt-w 85 testfile

For comparison, run the cat command to view the file content:

$ Cat testfile # view the content of the testfile file

Hello Linux!

Linux is a free Unix-type operating system.

This is a Linux testfile!

Linux

Linux

After fmt command is executed, the output result is as follows:

$ Fmt-w 85 testfile # specify 85 characters in the shuffling width

Hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile!

Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.