Multiple choice technology operating systems

How to display only hidden files in UNIX?

  1. ls -a

  2. ls -a|grep "^."

  3. ls -a|grep "^."

  4. ls -ltra

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To display only hidden files (files starting with a dot), you use 'ls -a' to list all files including hidden ones, then pipe to grep with pattern '^.\' which matches lines starting with a dot. Option A shows all files including non-hidden ones. Option B uses '^.\' which incorrectly excludes hidden files. Option D shows all files in long format with time reversed, not just hidden files. The grep filter in option C correctly isolates the dot-prefixed entries.