When using SED, it’s important that you have an understanding of regular expressions. The characters are used to tell the command how to handle a sequence of characters. For example, square brackets and round brackets are important:
- [ABC]: A character class is used when looking for a match from a group of letters, digits, or symbols; i.e. either A or B or C.
- (ABC): A character group describes a fixed term; so it’s ABC in this order.
Wildcards allow regular expressions to also search for only parts of terms. You can use two different variants:
- .: The full stop replaces exactly one character.
- *: The asterisk replaces any number of characters.
In addition, regular expressions give you the possibility to determine the frequency of character (-combinations) more precisely.
- ?: The question mark indicates that a term may occur once or not at all.
- +: The plus sign specifies that the character occurs more than once, but at least once.
- {0,n}: With a number inside curly brackets you specify exactly how often the character combination may occur. If you enter two values (separated by a comma), you determine the minimum and maximum repetitions.
Finally, when dealing with Linux and SED, you can also include logical characters that help you, for example, when linking or nesting search queries.
- |: A pipe stands between two terms and symbolises an alternative of the two.
- ^: The circumflex (written directly in front of a term) negates it; this string must therefore not occur.
So, with these characters you modify the input in the SED command and in this way, you can perform complex tasks.