There are two metacharacters used to specify that the string is at the beginning or end of the line. The caret (^) is a form that indicates the beginning of the word regular. The dollar sign ($) is the normal form of a single character that indicates the end of a line. These are often referred to as "locators," because they limit the match to a specific location. For example, you can use the following expression to print a line beginning with first:
^first
There is no ^ meta-character. This expression will print a random line that includes first.
Usually. Use VI to enter the text to be processed by troff, and do not want the space to be the end of today's line. Assuming that you want to find (and delete) them, the following normal expressions can match the line with one or more spaces at the end:
--*$
Troff requests and macros must be entered at the beginning of the row. They are a two-character string. preceded by a period.
Suppose a request or a macro has a number of parameters. Then it usually has a space behind it. The regular expressions used to search for such requests are:
^\... -
This expression matches the line with a period at the beginning of the row, followed by a two-character string, and then a space.
The ability to match a blank line using two contiguous positional metacharacters, namely: ^$
The ability to use this pattern to calculate the number of empty lines in a file, using the Count option-C in grep:
$ grep-C' ^$ 'Ch04
5
Suppose you want to use SED to delete empty rows. So this is a very practical form of expression.
The following regular expressions can be used to match blank lines, even if they include spaces:
^-*$
Same. The ability to match an entire row with the following expression: ^.*$
In sed (and grep), it is only special when "^" and "$" are present at the beginning or end of the current form.
So "^abc" means "match only the letters A, B, and C at the beginning of the line, and" ab^c "means" match A, B, character ^, and then C "at any position in the line.
This is used for the same "$".
It is different in awk. "^" and "$" are always special. Even if they may make the written regex match whatever it is.
To be able to say, in awk, when you want to match the character "^" or "$", no matter where it is in the normal form, it should be escaped with a backslash.
References: http://www.linuxawk.com/communication/441.html
Linux Normal table-positional meta-characters