Description
Given a data file, we want to left justify the field consists of 11th through 20th columns by removing leading spaces of them. Data not belonging to this field should not be altered.
Raw Input Desired Output
123456789012345678901234567890
Kevin      GLX-134  Ford
Grace        LG-778NCiteron
Kelly       PQ-3312  Audi
Joseph       X-YZ79  Honda
123456789012345678901234567890
Kevin     GLX-134   Ford
Grace     LG-778N   Citeron
Kelly     PQ-3312    Audi
Joseph    X-YZ79     Honda
Script and Comments
Script1
[ 1] s/^.{20}/&\n/
[ 2] s/^(.{10})( *)([^\n]*)\n/\1\3\2/
Comments
  1. To facilitate reading, we use ERE (Extended RE) where blackslashing {} and () are not needed. Be sure to use '-r' option of sed to make sed interpret REs as EREs rather than BREs (Basic RE).
  2. Step [1] is used to insert a mark between 20th and 21st column.
  3. To left justify the field in question while not alter other ones, we move leading spaces (may not exist) of the field to the end of it.
  4. 3 pairs of parentheses are used in Step [2], where
    • the first one contains the first ten columns,
    • the second one contains leading spaces of the field in question, and
    • the third one contains other parts of the field.