Massaging data with fmt and sed


I had to cleanup a few documents today, and wanted to transform the text into an 80-column file with 4 spaces in the left margin. This was easily accomplished with the following shell pipeline:

$ cat messedup.txt | sed 's/^/ /' | fmt -80 > messedup.txt.new

I was lucky that the file had a basic form, since it minimized the number of items in my pipeline. :)

This article was posted by Matty on 2005-09-23 23:51:00 -0400 -0400