String Pattern Matching

The shell provides a powerful set of string pattern-matching operators that manipulate pathnames and other strings. These operators can delete from strings prefixes or suffixes that match patterns. The four operators are listed in Table 13-4.

Table 13-4. String Operator
# Removes minimal matching prefixes
## Removes maximal matching prefixes
% Removes minimal matching suffixes
%% Removes maximal matching suffixes

The syntax for these operators is

						${varname op pattern}
					

In this syntax op is one of the operators listed in Table 13-4, and pattern is a match pattern similar to that used for filename generation. These operators ...

Get A Practical Guide to Red Hat® Linux® 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.