Next Hold Space 22

Heading translation in sed

  • The interesting part is:

        /^\(.\)\1\1*$/ { x; 
                         y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;
                                      x; d;
                       }
  • /^\(.\)\1\1*$/ is a pattern

    • it matches lines that have 2 or more occurrences of the same character

    • and nothing else

  • For these lines, we first retrieve the hold space (x)

    • (that's the previous line of input)

  • Translate to upper case (y/.../.../)

  • Put it back in the hold space as if it had been uppercase all along

  • And skip to the next line of input, printing nothing d


Next Next