POSIX/Unix filenames and validity: Which of the following is an invalid filename on a typical Unix-like system (plain files in a standard directory, not including reserved names)?

Difficulty: Easy

Correct Answer: None of the above

Explanation:


Introduction / Context:
Unix-like systems are permissive about filenames. Knowing what is valid helps avoid needless errors when creating, copying, or scripting across files. Unlike DOS-era systems with strict 8.3 naming, modern Unix supports long names, spaces, and punctuation (with a few caveats).



Given Data / Assumptions:

  • The examples are to be interpreted as ordinary filenames within a normal directory.
  • We are not dealing with special device files, reserved DOS names, or shell wildcards that the shell expands unless quoted.
  • No path separators (/) or NUL bytes are present in the names given.


Concept / Approach:

Unix filenames can contain any byte except the NUL character and the forward slash. Case is significant (TRY and try are different). Spaces and leading dots are allowed, although they may require quoting or escaping at the shell prompt.



Step-by-Step Solution:

Check 'shutry': letters only, valid.Check 'TRY': uppercase letters are valid; case sensitivity is normal on Unix.Check 'trial': letters only, valid.Check 'my .file': contains a space and a dot; still valid, though quoting may be needed (for example, '"my .file"').Since all listed names are permissible, select 'None of the above'.


Verification / Alternative check:

On a Unix shell, running touch "my .file" creates the file successfully. ls -l then lists it normally. This demonstrates that spaces and dots are permissible in filenames.



Why Other Options Are Wrong:

  • shutry, TRY, trial, my .file: Each is a valid filename under POSIX constraints (no / and no NUL), so none is invalid.
  • Therefore the catch-all correct response is 'None of the above'.


Common Pitfalls:

Assuming spaces or leading dots are forbidden. Spaces require quoting to avoid word-splitting by the shell, and a leading dot merely marks a file as hidden in many tools. Truly invalid characters are only the forward slash and the NUL byte; other restrictions may come from specific filesystems or tools.



Final Answer:

None of the above

More Questions from Unix

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion