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 (
d
for 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 āgrep
cannot 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 ā