Point to any file with an absolute or a relative path, and act on several files at once.
Open this lesson in KodokonThere are two ways to say where a file is, exactly like giving an address. The absolute path is the full postal address: it starts from the root and works from anywhere. On macOS and Linux it always starts with a forward slash /, for example /home/yoann/my-project/index.html. On Windows it starts with a drive letter, for example C:\Users\yoann\my-project.
The relative path, on the other hand, is more like "second door on the left": it starts from the folder you are currently in. Three symbols are enough to express anything. The dot . means the current folder. The two dots .. mean the parent folder. The tilde ~ means your home folder. You chain them together with slashes to build a route.
cd /home/yoann/my-project
cd ~/my-project
cd ../other-project
cat ./src/index.html
cp ../photo.jpg .When you need to act on ten files, you are not going to type ten commands. The shell recognizes wildcards, also called patterns: special characters that stand in for one or more unknown characters. The star * stands for any sequence of characters, including none at all. The question mark ? stands for exactly one character. Square brackets [ ] accept any one of the characters listed inside them.
ls *.html
ls src/*.css
ls photo-?.jpg
ls report-202[45].pdf
cp *.txt archive/One last detail that prevents a lot of trouble: on macOS and Linux, file names are case-sensitive. Photo.jpg and photo.jpg are two different files, and ls photo* will not find the first one. Windows makes no such distinction. So a project that works on your Windows machine can fail on the Linux server that hosts it, purely because of one capital letter.
./~photo- and .jpg.$ ls
photo-1.jpg photo-2.jpg photo-10.jpg
$ ls ___
photo-1.jpg photo-2.jpg.tmp file safely. What precaution do you take?rm *.tmp then check with lsls *.tmp first to see what will be deleted