SED: Align lines LEFT instead of right on a 79-column width
I've seen the SED oneliner:
sed -e :a -e 's/^.\{1,78\}$/ &/;ta'
I want to do the same bij I want to align LEFT. So the question is how can I get a 79 column width with the text alingned LEFT?
After the clarification in the comment: you can archieve that like this:
fold -w79 yourfile | sed -e :a -e 's/^.\{0,78\}$/& /;ta'
The fold
folds long lines and the sed
appends spaces to short lines. Note tha the /& /
part has the space right of the &
. This appends the space (&
means the unmodified line).
I also changed the {1,78}
to {0,78}
, thus empty lines will also be expanded.