Wildcards · Диалекты (wildcards)
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Эта страница требует современного браузера (с поддержкой 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:
Русский
Одна команда, много файлов
- Маска (wildcard) — символ, обозначающий «любой». Самый распространенный —
*. *.txtозначает «любое имя, заканчивающееся на.txt». Оболочка сама подставит совпадения:
ls *.txt
English
The two main wildcards
*matches any number of characters (even none).?matches exactly one character.
- So
file?.txtmatchesfile1.txtandfileA.txt, but notfile10.txt.
Русский
Два основных типа масок
*соответствует любому количеству символов (включая ноль).?совпадает ровно с одним символом.
ls file?.txt
- Так что
file?.txtсовпадает сfile1.txtиfileA.txt, но не сfile10.txt.
English
Be careful with delete
- Wildcards are powerful — and that cuts both ways:
- That deletes every
.txtfile at once. Runls *.txtfirst to see exactly what will go.
Русский
Будьте осторожны с удалением
- Двоеточие (wildcard) — мощная вещь, и это работает в обе стороны:
rm *.txt
- Это удалит все файлы
.txtсразу. Сначала выполнитеls *.txt, чтобы увидеть, что именно будет удалено.
English
Common mistakes
*matches any text and?matches one character.- Quote a name that has spaces, or the shell splits it into two.
Русский
Распространенные ошибки
*совпадает с любым текстом, а?— с одним символом.- Оберните имя в кавычки, если в нем есть пробелы, иначе оболочка разобьет его на две части.
List only the .txt files using the * wildcard: ls *.txt. · Выведите только файлы .txt, используя диалект *: ls *.txt.
Delete all the .txt files at once with rm *.txt. The check lists what is left. · Удалите все файлы .txt разом с помощью rm *.txt. Проверка покажет, что осталось.