.TH JUSTIFY 1 "October 2025" "justify 0.2.0" "User Commands" .SH NAME justify \- format and justify text to a specified line width .SH SYNOPSIS .B justify [\fB-w\fR \fIWIDTH\fR] .SH DESCRIPTION .B justify reads text from standard input, formats it into lines of a specified width, and justifies the text so that both the left and right margins are aligned. Justification is achieved by distributing extra spaces between words so that each line (except the last line of a paragraph) is exactly the specified width. The last line of each paragraph is left-aligned and not justified. .SH OPTIONS .TP .BR \-w ", " \-\-width " " \fIWIDTH\fR Set the line width for justification. The default is 72 characters. .SH USAGE Input is read from standard input. Output is written to standard output. Any error output is written to standard error. To justify a file to 80 columns: .RS .nf $ justify -w 80 < input.txt .fi .RE To justify text from a pipe: .RS .nf $ echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit." | justify .fi .RE .SH EXIT STATUS .TP .B 0 Success. .TP .B 1 An error occurred (e.g., read error). .SH NOTES Before appending a word to the current line, the program ensures there is enough space for the word (and a space if not the first word). If not enough space remains, the current line is flushed (justified) and a new line is started. .SH UNICODE SUPPORT The program supports UTF-8 encoded text and correctly handles multi-byte characters when calculating line widths. Display width is determined using Unicode East Asian Width properties, so full-width and wide characters (such as CJK characters) are counted as taking two columns, while most other characters take one column. .SH AUTHOR Eugene Triguba .SH SEE ALSO fmt(1), fold(1)