通配符
此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
One command, many files
- A wildcard is a symbol that stands for "anything". The most common is
*. *.txtmeans "every name ending in.txt". The shell fills in the matches for you:
ls *.txt

English
The two main wildcards
*matches any number of characters (even none).?matches exactly one character.
ls file?.txt
- So
file?.txtmatchesfile1.txtandfileA.txt, but notfile10.txt.
English
Be careful with delete
- Wildcards are powerful — and that cuts both ways:
rm *.txt
- That deletes every
.txtfile at once. Runls *.txtfirst to see exactly what will go.
English
Common mistakes
*matches any text and?matches one character.- Quote a name that has spaces, or the shell splits it into two.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
List only the .txt files using the * wildcard: ls *.txt.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
删除 所有 the .txt files at once with rm *.txt. The check lists what is left.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
This folder holds file1.txt, fileA.txt and file10.txt. List only file1.txt and fileA.txt with 一个 ls and a wildcard, so that file10.txt is left out.