What is the purpose of the -d argument to ls? [duplicate]
This question already has an answer here:
What is the meaning of ls -d ?
4 answers
why does ls -d also list files, and where is it documented?
7 answers
I currently study bash commands and in my tutuorial I have this command:
ls -d
I try to understand what is meaning of -d with ls I tried to run it on my computer and I get this result -> .
I tried to look in man ls and it says :
-d, --directory
list directories themselves, not their contents
But this doesn't say to me much.
Any idea why should I use -d with ls command?
what does it do?
directory ls arguments
marked as duplicate by Jeff Schaller, Stephen Kitt, Christopher, GAD3R, roaima Jan 28 at 16:47
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
migrated from stackoverflow.com Jan 28 at 16:38
This question came from our site for professional and enthusiast programmers.
|
show 10 more comments
This question already has an answer here:
What is the meaning of ls -d ?
4 answers
why does ls -d also list files, and where is it documented?
7 answers
I currently study bash commands and in my tutuorial I have this command:
ls -d
I try to understand what is meaning of -d with ls I tried to run it on my computer and I get this result -> .
I tried to look in man ls and it says :
-d, --directory
list directories themselves, not their contents
But this doesn't say to me much.
Any idea why should I use -d with ls command?
what does it do?
directory ls arguments
marked as duplicate by Jeff Schaller, Stephen Kitt, Christopher, GAD3R, roaima Jan 28 at 16:47
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
migrated from stackoverflow.com Jan 28 at 16:38
This question came from our site for professional and enthusiast programmers.
That said, comparecd /; ls -d *withcd /; ls *-- the difference will be obvious.
– Charles Duffy
Jan 28 at 16:27
In other words-dwill only show you folders, not files.
– Robert Harvey
Jan 28 at 16:27
2
@RobertHarvey, eh?-dwill still show files, if passed names of any files on its argument list; what it won't show is the contents of directories named on its argument list (or., as the default directory forlsto operate on if no non-option arguments are given).
– Charles Duffy
Jan 28 at 16:27
I don't understand what you just said. Clearly the documentation could use some improvement.
– Robert Harvey
Jan 28 at 16:29
1
ls /vsls -d /would be a simpler demonstration of the difference.
– chepner
Jan 28 at 16:35
|
show 10 more comments
This question already has an answer here:
What is the meaning of ls -d ?
4 answers
why does ls -d also list files, and where is it documented?
7 answers
I currently study bash commands and in my tutuorial I have this command:
ls -d
I try to understand what is meaning of -d with ls I tried to run it on my computer and I get this result -> .
I tried to look in man ls and it says :
-d, --directory
list directories themselves, not their contents
But this doesn't say to me much.
Any idea why should I use -d with ls command?
what does it do?
directory ls arguments
This question already has an answer here:
What is the meaning of ls -d ?
4 answers
why does ls -d also list files, and where is it documented?
7 answers
I currently study bash commands and in my tutuorial I have this command:
ls -d
I try to understand what is meaning of -d with ls I tried to run it on my computer and I get this result -> .
I tried to look in man ls and it says :
-d, --directory
list directories themselves, not their contents
But this doesn't say to me much.
Any idea why should I use -d with ls command?
what does it do?
This question already has an answer here:
What is the meaning of ls -d ?
4 answers
why does ls -d also list files, and where is it documented?
7 answers
directory ls arguments
directory ls arguments
edited Jan 28 at 16:39
Jeff Schaller
41k1056131
41k1056131
asked Jan 28 at 16:25
Michael
marked as duplicate by Jeff Schaller, Stephen Kitt, Christopher, GAD3R, roaima Jan 28 at 16:47
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
migrated from stackoverflow.com Jan 28 at 16:38
This question came from our site for professional and enthusiast programmers.
marked as duplicate by Jeff Schaller, Stephen Kitt, Christopher, GAD3R, roaima Jan 28 at 16:47
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
migrated from stackoverflow.com Jan 28 at 16:38
This question came from our site for professional and enthusiast programmers.
That said, comparecd /; ls -d *withcd /; ls *-- the difference will be obvious.
– Charles Duffy
Jan 28 at 16:27
In other words-dwill only show you folders, not files.
– Robert Harvey
Jan 28 at 16:27
2
@RobertHarvey, eh?-dwill still show files, if passed names of any files on its argument list; what it won't show is the contents of directories named on its argument list (or., as the default directory forlsto operate on if no non-option arguments are given).
– Charles Duffy
Jan 28 at 16:27
I don't understand what you just said. Clearly the documentation could use some improvement.
– Robert Harvey
Jan 28 at 16:29
1
ls /vsls -d /would be a simpler demonstration of the difference.
– chepner
Jan 28 at 16:35
|
show 10 more comments
That said, comparecd /; ls -d *withcd /; ls *-- the difference will be obvious.
– Charles Duffy
Jan 28 at 16:27
In other words-dwill only show you folders, not files.
– Robert Harvey
Jan 28 at 16:27
2
@RobertHarvey, eh?-dwill still show files, if passed names of any files on its argument list; what it won't show is the contents of directories named on its argument list (or., as the default directory forlsto operate on if no non-option arguments are given).
– Charles Duffy
Jan 28 at 16:27
I don't understand what you just said. Clearly the documentation could use some improvement.
– Robert Harvey
Jan 28 at 16:29
1
ls /vsls -d /would be a simpler demonstration of the difference.
– chepner
Jan 28 at 16:35
That said, compare
cd /; ls -d * with cd /; ls * -- the difference will be obvious.– Charles Duffy
Jan 28 at 16:27
That said, compare
cd /; ls -d * with cd /; ls * -- the difference will be obvious.– Charles Duffy
Jan 28 at 16:27
In other words
-d will only show you folders, not files.– Robert Harvey
Jan 28 at 16:27
In other words
-d will only show you folders, not files.– Robert Harvey
Jan 28 at 16:27
2
2
@RobertHarvey, eh?
-d will still show files, if passed names of any files on its argument list; what it won't show is the contents of directories named on its argument list (or ., as the default directory for ls to operate on if no non-option arguments are given).– Charles Duffy
Jan 28 at 16:27
@RobertHarvey, eh?
-d will still show files, if passed names of any files on its argument list; what it won't show is the contents of directories named on its argument list (or ., as the default directory for ls to operate on if no non-option arguments are given).– Charles Duffy
Jan 28 at 16:27
I don't understand what you just said. Clearly the documentation could use some improvement.
– Robert Harvey
Jan 28 at 16:29
I don't understand what you just said. Clearly the documentation could use some improvement.
– Robert Harvey
Jan 28 at 16:29
1
1
ls / vs ls -d / would be a simpler demonstration of the difference.– chepner
Jan 28 at 16:35
ls / vs ls -d / would be a simpler demonstration of the difference.– chepner
Jan 28 at 16:35
|
show 10 more comments
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
That said, compare
cd /; ls -d *withcd /; ls *-- the difference will be obvious.– Charles Duffy
Jan 28 at 16:27
In other words
-dwill only show you folders, not files.– Robert Harvey
Jan 28 at 16:27
2
@RobertHarvey, eh?
-dwill still show files, if passed names of any files on its argument list; what it won't show is the contents of directories named on its argument list (or., as the default directory forlsto operate on if no non-option arguments are given).– Charles Duffy
Jan 28 at 16:27
I don't understand what you just said. Clearly the documentation could use some improvement.
– Robert Harvey
Jan 28 at 16:29
1
ls /vsls -d /would be a simpler demonstration of the difference.– chepner
Jan 28 at 16:35