Home >Operation and Maintenance >Linux Operation and Maintenance >What are the linux command wildcards?
There are 4 common command wildcards in Linux: 1. "*", matches any number, including zero characters; 2. "?", matches a single character; 3. "[]", matches the characters in brackets Any specified character; 4. "{}", specifies a set of optional options.
The operating system of this tutorial: Linux5.18.14 system, Dell G3 computer.
Wildcard characters in Linux system commands refer to placeholders used to find and match file names. When using them, you need to understand some basic wildcard characters and their usage.
The following are several common wildcard characters:
1, *
matches any number (including zero) characters | ls * .txt (list all files ending with .txt)
2, ?
match a single character | ls ?.txt (list all files ending with one character plus .txt )
3, []
Matches any character given in brackets | ls [abc].txt (lists characters starting with a, b or c and ending with .txt File)
4, {}
Specify the set of options | cp file{1,2}.txt dir (Put file1.txt and file2.txt into the dir directory)
Usage example:
Use * to find all files ending with .log under /var/log: `ls /var/log/*.log`
Use ? to find all log file names in the /var/log/ directory (file names with different numbers of letters can only be matched according to ?): `ls /var/log/*.log?`
Use [] in the ls command to match any folder starting with n, o, or p: `ls [nop]*`
Use {} to display two files: `echo {foo,bar}`
The above is the detailed content of What are the linux command wildcards?. For more information, please follow other related articles on the PHP Chinese website!