User Tools

Site Tools


sed:align:center_all_text_in_the_middle_of_79-column_width

SED - Align - Center all text in the middle of 79-column width

sed  -e :a -e 's/^.\{1,77\}$/ & /;ta'                     # method 1
sed  -e :a -e 's/^.\{1,77\}$/ &/;ta' -e 's/\( *\)\1/\1/'  # method 2

NOTE:

  • In method 1, spaces at the beginning of the line are significant, and trailing spaces are appended at the end of the line.
  • In method 2, spaces at the beginning of the line are discarded in centering the line, and no trailing spaces appear at the end of lines.
sed/align/center_all_text_in_the_middle_of_79-column_width.txt · Last modified: 2022/06/14 08:22 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki