- Practice
- About 15 min
- 5 practice questions
Practice: reading paths, wildcards and file extensions
Decode absolute and relative paths, use . and .. correctly, predict which files a wildcard pattern matches, and name the file type behind common extensions.
If something looks wrong, please tell us.
Path and extension questions are puzzles with exact answers. If you read a path one part at a time and know what the special symbols mean, you will not make mistakes. This lesson sets out the method and the symbols, with worked examples.
Reading a path, step by step
- Find the start: a drive letter such as D: (Windows) or the root / (Linux), or neither, which means a relative path.
- Read each folder from left to right; each one is inside the one before it.
- The last part is usually the file. The folder just before it is the file's parent.
- The part after the last dot is the extension, which gives the file type.
Special path symbols
| Symbol | Meaning | Example |
|---|---|---|
| . | The current folder | ./notes.txt is notes.txt in the folder you are in |
| .. | The parent folder, one level up | cd .. moves up one level |
| / at the start (Linux) | The root directory | /home/ravi starts at the top of the tree |
| ~ (Linux shells) | Your home folder | ~/Documents is /home/yourname/Documents |
| \ (Windows) or / (Linux) | Separator between folders | D:\Office\Accounts or /home/ravi/Pictures |
Wildcards
Command lines and search boxes accept wildcards: the asterisk stands for any number of characters (including none), and the question mark stands for exactly one character.
| Pattern | Matches | Does not match |
|---|---|---|
| *.odt | notes.odt, letter.odt | sheet.ods, notes.odt.bak |
| data?.csv | data1.csv, dataA.csv | data.csv, data12.csv |
| report_??.pdf | report_01.pdf, report_ab.pdf | report_1.pdf, report_123.pdf |
Extensions in families
| Kind | OpenDocument (LibreOffice) | Microsoft Office | Others |
|---|---|---|---|
| Document | .odt | .docx (older .doc) | .txt, .rtf, .pdf |
| Spreadsheet | .ods | .xlsx (older .xls) | .csv |
| Presentation | .odp | .pptx (older .ppt) | - |
| Image | - | - | .jpg, .png, .gif, .bmp |
| Audio and video | - | - | .mp3, .wav; .mp4, .avi |
| Archives and programs | - | - | .zip, .tar.gz; .exe (Windows), .deb (Debian and Ubuntu packages), .sh (shell script) |
Worked example 1: a relative path
You are in /home/ravi/Documents and type cd ../Pictures. Step 1: .. takes you up one level, to /home/ravi. Step 2: Pictures is then entered from there. Result: /home/ravi/Pictures. A common wrong answer is /home/ravi/Documents/Pictures, which forgets that .. moved you up first.
Worked example 2: a wildcard question
A folder holds data.csv, data7.csv, data12.csv and mydata7.csv. Which match data?.csv? The pattern needs the exact letters data, then exactly one character, then .csv. data7.csv matches. data.csv has no character in the gap, data12.csv has two, and mydata7.csv has extra letters in front. Only data7.csv matches.
Worked example 3: decode a Windows path
D:\Office\Accounts\Bills\march.pdf. Drive D:. Folder Office, inside it Accounts, inside it Bills. The file march.pdf is in Bills, so Bills is its parent, and the parent of Bills is Accounts. The extension .pdf means a Portable Document Format file.
Read left to right; the folder before the file is its parent. Dot = here, dot-dot = one level up. In wildcards the question mark is exactly one character; the asterisk is any number.
Key takeaways: split a path into its parts, apply .. before anything after it, count characters for the question mark, and learn extensions in families so that .ods and .xlsx, .odp and .pptx are never confused.
Check your understanding
-
1. In the path D:\Office\Accounts\Bills\march.pdf, what is the parent folder of Bills?
- Office
- Accounts
- D:
- march.pdf
Show answer
Answer: B. Each folder is inside the one before it, so Bills is inside Accounts. Office is one level higher still, D: is the drive and march.pdf is the file.
-
2. Which files does the pattern *.odt match?
- Every file in the folder
- Only folders
- notes.odt and letter.odt, but not sheet.ods
- Only files with no extension
Show answer
Answer: C. The asterisk stands for any name, but the name must end in .odt, so notes.odt and letter.odt match and sheet.ods does not.
-
3. Which file matches the pattern data?.csv?
- data.csv
- data12.csv
- data7.csv
- mydata7.csv
Show answer
Answer: C. The question mark stands for exactly one character, so only data7.csv fits. data.csv has no character there, data12.csv has two, and mydata7.csv has extra letters in front.
-
4. In the command cd .., the two dots mean:
- The current folder
- The parent folder, one level up
- The root folder
- The home folder
Show answer
Answer: B. Two dots mean the parent folder. One dot means the current folder, / the root, and ~ the home folder on Linux.
-
5. Which extension belongs to a software package for Debian and Ubuntu Linux?
- .exe
- .pptx
- .mp4
- .deb
Show answer
Answer: D. Debian and Ubuntu install software from .deb packages. A .exe file is a Windows program, .pptx is a presentation and .mp4 a video.
Sign in to keep track of the lessons you finish.