Skip to content

Fold and fmt snippets

Terminal window
# View file and fold lines are 60 characters and on spaces
cat file.txt | fold -s -w 60
# -s - fold on spaces
# Fold file and output to file
fold -s -w 60 < file.txt > foldedfile.txt
Terminal window
# Reformat file
fmt file.txt
# Reformat output
cat file.txt | fmf
# Reformat file with uniform spaces (1 space between words, 2 between paragraphs)
fmt -u file.txt