Wildcards are building blocks for patterns that match files or directories. When you use ls
or any other command that works with files and directories, you provide a path (recall relative and absolute paths from the previous lesson). When you refer to a path, you can also use wildcards that will possibly match multiple files or directories at once.
Basic wildcards are:
Example:
ls docs/photos
saturday.jpg sunday.jpg dog.jpg machine.jpg scan.tiff scan2.tiff
ls docs/s*
saturday.jpg sunday.jpg
ls docs/*.jpg
saturday.jpg sunday.jpg dog.jpg machine.jpg
Also, remember the shortcut for "home directory" — it's ~
. You can use it in paths. For example, if your home directory is /home/michael
, then ~/docs
is the same as /home/michael/docs
.
mkdir
to create directorymkdir -p
to create multiple levels of directories (e.g. mkdir -p dir1/dir2/dir3
)touch
to change the date of a file or create a new file (e.g. touch newfile.txt
)mv
to move or rename a file or a directory (e.g. mv old_name new_name
)rm
to delete a file (e.g. rm readme.txt
)rm -r
to delete a directory and all the directories inside it (e.g. rm -r photos
)The Hexlet support team or other students will answer you.
Programming courses for beginners and experienced developers. Start training for free
Our graduates work in companies:
Sign up or sign in
Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.