LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-27-2016, 11:59 AM   #1
krishnar
Member
 
Registered: May 2016
Posts: 32

Rep: Reputation: Disabled
ls -d


Hi guys,

I am wondering what does ls -d command do?

ubuntu@Ubuntu-Machine:~$ ls -d
.
ubuntu@Ubuntu-Machine:~$

ls helps shows it will list the directories.

-d, --directory list directory entries instead of contents,and do not dereference symbolic links

But I don't see it listing all the directories instead on '.'.
 
Old 05-27-2016, 12:28 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
Quote:
Originally Posted by krishnar View Post
Hi guys,
I am wondering what does ls -d command do?

ls helps shows it will list the directories.

-d, --directory list directory entries instead of contents,and do not dereference symbolic links

But I don't see it listing all the directories instead on '.'.
Right...because ls by default, references the current directory. If you want to see just the directories within a directory, use "ls -d */"
 
Old 05-27-2016, 07:36 PM   #3
Fred Caro
Senior Member
 
Registered: May 2007
Posts: 1,007

Rep: Reputation: 167Reputation: 167
TB0ne.

Quote:
ls -d */"
gets you

Quote:
>
but

Quote:
ls -d */
lists just the directories inside the current directory you are in, something to do with builtin commands.

Fred.
 
Old 05-28-2016, 04:55 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
lol
 
Old 05-28-2016, 01:27 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
Quote:
Originally Posted by Fred Caro View Post
TB0ne.

gets you

but lists just the directories inside the current directory you are in, something to do with builtin commands.

Fred.
Right...which is exactly the same command I posted initially. You just put in a trailing double-quote, which is what I wrapped the command in when I posted it. There was also a LEADING double-quote too, if you'll notice.
 
Old 05-28-2016, 07:35 PM   #6
Fred Caro
Senior Member
 
Registered: May 2007
Posts: 1,007

Rep: Reputation: 167Reputation: 167
oops,

yes "without quotes" use this: ...

apologies,

Fred.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration