190. Which command is suitable to list out all the directories in the working directory, in linux/unix
environment?
A. 𝐼𝑠 − 1|𝑔𝑟𝑒𝑝 𝑑
⋀
B. 𝑔𝑟𝑒𝑝 𝑑
⋀
|𝐼𝑠 − 1
C. 𝐼𝑠 − 1|𝑔𝑟𝑒𝑝 𝑑
⋀
D. 𝐼𝑠|𝑔𝑟𝑒𝑝 𝑑𝑖�
Explanation:
To list only directories from the current working directory in a Unix/Linux shell, you can use:
Breakdown of the Command:
-
ls -l:-
Lists files and directories in long format (detailed view), where each line starts with the file type (
dfor directory,-for file, etc.)
-
-
grep ^d:-
Filters only the lines that start (
^) withd, i.e., directories.
-
This way, only directories are listed from the output of ls -l.
Why Other Options Are Incorrect:
-
B.
grep d^ | ls -l: Incorrect syntax and reversed order –grepcannot pipe intols. -
C. Repeats A: Appears to be a typo/duplicate.
-
D.
ls | grep dir: This command assumes directory names contain “dir,” which is not general or reliable.
Conclusion:
To reliably list only directories, the command:
is the most suitable.
Correct Answer: A. ls -l | grep ^d



8 Comments
Suman bhakar
April 15, 2025Best explanation
Khusbi yadav
April 17, 2025👍
Yashika Rajoriya
April 17, 2025✅
Shalu Choudhary
April 17, 2025👍
Prami Masih
April 22, 2025Done sir ji
SEETA CHOUDHARY
April 22, 2025Done ✅
yogesh sharma
April 29, 2025Sir ye wala upr se gya 😅
Komal Sharma
May 12, 2025Done ✅