Multiple choice technology operating systems

Display only directories from a particular location/folder

  1. ls -d

  2. ls -l | grep "$d"
  3. ls -l | grep "^d"

  4. ls -ltr | grep -d

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

In ls -l output, the first character indicates file type: 'd' for directory, '-' for regular file. grep "^d" filters lines starting with 'd', showing only directories. Option A's ls -d lists directory entries but doesn't filter contents by type; Option B uses a variable pattern that won't match the directory marker.