LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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, 12:59 PM   #1
krishnar
LQ Newbie
 
Registered: May 2016
Posts: 9

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, 01:28 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,919

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
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, 08:36 PM   #3
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
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, 05:55 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
lol
 
Old 05-28-2016, 02:27 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,919

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
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, 08:35 PM   #6
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
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




All times are GMT -5. The time now is 12:14 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration