in reply to removing all whitespace but newlines
When there never are spaces in the end of the 12 characters, and you're sure all lines do contain 12 non-space characters:
perl -i -lpe 's/\s+^//' myfile
Or the foolproof way:
perl -lne '/^.{1,12}/; printf "%-12s\n",$&' myfile
I think I just started playing perlgolf...
|
|---|