How can I match the page break character in a regular expression?

8,070

That seems to be the good old form feed character, described in man ascii as:

Oct   Dec   Hex   Char
------------------------------------------
014   12    0C    FF  '\f' (form feed)

(Not mentioned there, but ^L's code is the same 12.)

Then in bash any of these should work:

grep -v $'\f' file

grep -v $'\cL' file

grep -v $'\x0C' file
Share:
8,070

Related videos on Youtube

Matthew
Author by

Matthew

Updated on September 18, 2022

Comments

  • Matthew
    Matthew over 1 year

    Nano calls it ^L, but of course, typing something like

    $ grep -v "^\^L" file
    

    doesn't work. Its unicode codepoint is 000C. How can I match it in a regular expression?

  • Tim Kennedy
    Tim Kennedy over 12 years
    That explains why ^L works to clean up the the screen. For example, when you're on console, editing a file, and syslog is spamming the console. Thanks.
  • Matthew
    Matthew about 12 years
    in case anyone else is reading this to find out, kwrite regular expressions accept \f to represent this character
  • manatwork
    manatwork over 4 years
    “Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard.” — ANSI-C Quoting in Bash manual
  • Sandburg
    Sandburg about 2 years
    Just the third one works for me on Debian 10. $'\x0C'
  • manatwork
    manatwork about 2 years
    You are right @Sandburg, in that is confusing. The first 2 have a leading ^ as the question had, to anchor the expression to the beginning of a line. In change the last one finds the form feed character anywhere in the line, not only at the beginning. Unsure why I posted them like that. As the question doesn't mention explicitly the anchoring to the beginning of line, I removed it from the first 2. Thank you for pointing out this inconsistency.