Pattern matching

Using the double brackets, we can do more than just match strings, we can use pattern matching. For example, we may need to work exclusively with Perl scripts, files that end with .pl. We will be able to implement this easily within a condition by including the pattern as a match, as shown in the following example:

$ [[ $FILE = *.pl ]] && cp"$FILE" scripts/

Get Mastering Linux Shell Scripting 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.