Are there other useful wildcards?

0124

The primary wildcards used in shell environments are the asterisk (*), question mark (?), and square brackets ([]). However, there are additional patterns and constructs that can be useful:

  1. Exclamation Mark (!): Used within square brackets to negate a character class. For example, file[!1].txt will match any file that does not have 1 as the character in that position.

  2. Double Asterisk (**): In some shells (like Bash with shopt -s globstar enabled), it matches directories recursively. For example, **/*.txt will match all .txt files in the current directory and all subdirectories.

  3. Tilde (~): Represents the home directory of the current user. While not a wildcard in the traditional sense, it can be used in path expansions.

These constructs can enhance your file matching capabilities in shell scripting and command-line operations.

0 Comments

no data
Be the first to share your comment!