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 10-15-2013, 03:10 AM   #1
8ishan12
LQ Newbie
 
Registered: Oct 2013
Posts: 1

Rep: Reputation: Disabled
ls -d showing dot(.) as output why?


hi all
when i Giving command ls -d , it displaying dot only but according to concept it should be show the list f directory why?
 
Old 10-15-2013, 03:26 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
no
actually ls -d works exactly as expected.
when you give no argument to ls it will take . (current directory) by default. -d means list directory itself instead of its content (see man page)
 
Old 10-15-2013, 03:42 AM   #3
eklavya
Member
 
Registered: Mar 2013
Posts: 619

Rep: Reputation: 136Reputation: 136
According to manual
Code:
-d, --directory
              list directory entries instead of contents, and do not dereference symbolic links
Just like if you use
Code:
ls -ld
It shows the details of current directory.
If you want to see the list of sub-directories only (not the sub of sub-directories, only sub-directories), use this.
Code:
ls -l | grep "^d"
If you want to print name of sub directories only,
Code:
ls -l | grep "^d" | awk '{print $NF}'
 
Old 10-15-2013, 06:26 AM   #4
mddnix
Member
 
Registered: Mar 2013
Location: Bengaluru, India
Distribution: Redhat, Arch, Ubuntu
Posts: 498

Rep: Reputation: 137Reputation: 137
ls -d shows details of folder itself, not contents of folder.

For ex:
Code:
$ ls -l /media
total 53716
-rwxr-xr-x. 1 root root 48933020 Oct 12 16:54 NVIDIA-Linux-x86_64-319.60.run
-r--r--r--. 1 root root    22792 Oct 15 15:52 zd1211-firmware-1.4-4.el6.noarch.rpm
-r--r--r--. 1 root root  2767424 Oct 15 15:52 zenity-2.28.0-1.el6.x86_64.rpm
-r--r--r--. 1 root root   265820 Oct 15 15:52 zip-3.0-1.el6.x86_64.rpm
-r--r--r--. 1 root root    74284 Oct 15 15:52 zlib-1.2.3-29.el6.i686.rpm
-r--r--r--. 1 root root    74568 Oct 15 15:52 zlib-1.2.3-29.el6.x86_64.rpm
-r--r--r--. 1 root root    45008 Oct 15 15:52 zlib-devel-1.2.3-29.el6.i686.rpm
-r--r--r--. 1 root root    44984 Oct 15 15:52 zlib-devel-1.2.3-29.el6.x86_64.rpm
-r--r--r--. 1 root root    53400 Oct 15 15:52 zlib-static-1.2.3-29.el6.x86_64.rpm
-r--r--r--. 1 root root  2238420 Oct 15 15:52 zsh-4.3.10-5.el6.x86_64.rpm
-r--r--r--. 1 root root   464676 Oct 15 15:52 zsh-html-4.3.10-5.el6.x86_64.rpm

$ ls -ld /media
drwxr-xr-x. 2 root root 4096 Oct 15 15:52 /media
-d can also be used to display just folders:
Code:
$ ls -ld */
drwxrwxr-x. 55 madhu madhu 4096 Oct 15 11:53 Calibre Library/
drwxr-xr-x.  2 madhu madhu 4096 Oct 12 21:47 Desktop/
drwxr-xr-x.  2 madhu madhu 4096 Oct 14 02:03 Documents/
drwxr-xr-x.  3 madhu madhu 4096 Oct 13 22:46 Downloads/
drwxr-xr-x.  2 madhu madhu 4096 Oct 12 20:40 Music/
drwxr-xr-x.  3 madhu madhu 4096 Oct 12 21:45 Pictures/
drwxrwxr-x.  4 madhu madhu 4096 Oct 12 21:41 Programs/
drwxr-xr-x.  2 madhu madhu 4096 Oct 12 20:40 Public/
drwxr-xr-x.  2 madhu madhu 4096 Oct 12 20:40 Templates/
drwxrwxr-x. 38 madhu madhu 4096 Oct 14 11:29 test/
drwxr-xr-x.  2 madhu madhu 4096 Oct 14 22:11 Videos/
drwx------.  4 madhu madhu 4096 Oct 12 20:43 VirtualBox VMs/
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Eth0 not showing in ifconfig -a output rupeshm62 Linux - Desktop 7 12-07-2015 10:18 PM
conky not showing all output wilsid Linux - Software 0 06-05-2008 04:54 PM
How to avoid showing dot files sajipkuttan Linux - Newbie 3 02-27-2008 02:43 AM
df showing wrong output samac Slackware 9 12-08-2004 03:38 PM
useradd not accepting dot so i am not able to use dot in mail id hanu_raob Linux - General 5 05-13-2004 08:04 AM


All times are GMT -5. The time now is 06:30 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