The fold
command is used to limit the width of file columns. It reads content from the specified file, adds newline characters to columns that exceed the specified width, and then outputs the content to the standard output device. If no file name is specified or if the given file name is -
, the fold
command will read data from the standard input device.
fold [OPTION]... [FILE]...
-b, --bytes
: Count bytes instead of columns.-s, --spaces
: Break at spaces.-w, --width=WIDTH
: Usen
columns instead of the default value of80
.--help
: Display help information.--version
: Display version information.
Using the fold
command to wrap lines with a default maximum width of 80
characters.
fold file.txt
# fold command in Linux wraps each line in an input file to fit a specified width and prints it to the standard output. By default, it wraps lines at a maximum width of 80 columns but this is configurable. To fold input using the fold command, pass a file or standard input to the command.
Using the fold
command to wrap lines with a specified maximum width of 50
characters.
fold -w 50 file.txt
# fold command in Linux wraps each line in an input file to fit a specified width and prints it to the standard output. By default, it wraps lines at a maximum width of 80 columns but this is configurable. To fold input using the fold command, pass a file or standard input to the command.
Using the fold
command to wrap lines and using the -s
option to break lines at spaces to avoid breaking words.
fold -w 50 -s file.txt
# fold command in Linux wraps each line in an input file to fit a specified width and prints it to the standard output. By default, it wraps lines at a maximum width of 80 columns but this is configurable. To fold input using the fold command, pass a file or standard input to the command.
https://github.com/WindrunnerMax/EveryDay
https://www.computerhope.com/unix/ufold.htm
https://www.runoob.com/linux/linux-comm-fold.html
https://www.geeksforgeeks.org/fold-command-in-linux-with-examples/