Forrest logo
tool overview
On this page you find all important commands for the CLI tool fold. If the command you are looking for is missing please ask our AI.

fold

Fold is a command line tool used in Unix-like operating systems to wrap the input text into lines of a specified width. It is primarily used for formatting text files or adjusting the line length for readability.

  1. The 'fold' command takes input from a file or standard input and outputs the wrapped lines.
  2. By default, 'fold' wraps lines at 80 characters, but this can be customized.
  3. It inserts line breaks by breaking lines at word boundaries or after hyphens.
  4. It allows for single-byte and multi-byte character encoding.
  5. The command can be combined with other utilities in Unix pipelines to perform more complex text manipulation tasks.
  6. 'Fold' offers options to preserve existing line breaks or squeeze consecutive white spaces into a single space.
  7. It can also remove or replace specified characters or strings in the input text.
  8. The command provides an option to display line numbers in the output.
  9. 'Fold' is beneficial when preparing text for printing or viewing on terminals with limited width.
  10. It is a versatile tool that proves useful for formatting paragraphs, code output, or any text that requires consistent line lengths.

List of commands for fold:

  • fold:tldr:1a672 fold: Wrap each line to width "5" and break the line at spaces (puts each space separated word in a new line, words with length > 5 are wrapped).
    $ fold -w5 -s ${filename}
    try on your machine
    explain this command
  • fold:tldr:76de3 fold: Fold lines in a fixed width.
    $ fold --width ${width} ${filename}
    try on your machine
    explain this command
  • fold:tldr:84e0f fold: Wrap each line to width "30".
    $ fold -w30 ${filename}
    try on your machine
    explain this command
  • fold:tldr:aff4d fold: Wrap each line to default width (80 characters).
    $ fold ${filename}
    try on your machine
    explain this command
  • fold:tldr:ecb2f fold: Count width in bytes (the default is to count in columns).
    $ fold --bytes --width ${width_in_bytes} ${filename}
    try on your machine
    explain this command
  • fold:tldr:f7e0f fold: Break the line after the rightmost blank within the width limit.
    $ fold --spaces --width ${width} ${filename}
    try on your machine
    explain this command
tool overview