010-150 · Question #80
While deleting all files beginning with the letter a there was still the file Access.txt left. Assuming that it had the correct ownership, why was it not deleted?
The correct answer is E. Linux file names are case sensitive. Linux filesystems treat uppercase and lowercase letters as distinct characters, so the glob pattern 'a*' matches only files beginning with a lowercase 'a' and does not match 'Access.txt', which begins with an uppercase 'A'.
Question
While deleting all files beginning with the letter a there was still the file Access.txt left. Assuming that it had the correct ownership, why was it not deleted?
Options
- AFiles with extensions need a different treatment.
- Brm had to be called with the option -R to delete all files.
- CThe file Access.txt was probably opened by another application.
- DThe file Access.txt was hidden.
- ELinux file names are case sensitive.
How the community answered
(52 responses)- A4% (2)
- B2% (1)
- C6% (3)
- D17% (9)
- E71% (37)
Why each option
Linux filesystems treat uppercase and lowercase letters as distinct characters, so the glob pattern 'a*' matches only files beginning with a lowercase 'a' and does not match 'Access.txt', which begins with an uppercase 'A'.
File extensions carry no special meaning to the Linux kernel or to rm - a file named 'Access.txt' is treated identically to one named 'Access' with respect to deletion.
The -R flag enables recursive deletion of directory trees and their contents; it has no effect on glob pattern matching for ordinary files in the current directory.
On Linux, rm unlinks the directory entry immediately regardless of whether the file is held open by a process - an open file descriptor keeps the inode alive until closed, but rm does not fail or skip the file.
Hidden files in Linux are denoted by a leading dot in the filename (e.g., '.hidden'); 'Access.txt' starts with an uppercase letter, not a dot, so it is not hidden.
The Linux VFS layer and common filesystems such as ext4 and xfs are case-sensitive by design, meaning 'a' and 'A' are entirely different characters in a filename. A command like 'rm a*' expands the glob to filenames starting with lowercase 'a' only, leaving 'Access.txt' completely untouched because its first character 'A' does not satisfy the pattern.
Concept tested: Linux case-sensitive filenames and glob pattern matching
Source: https://www.gnu.org/software/bash/manual/bash.html#Pattern-Matching
Topics
Community Discussion
No community discussion yet for this question.