WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: listing links (ls -l)  (Read 3545 times)

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
listing links (ls -l)
« on: September 24, 2009, 12:27:08 PM »
I'm not sure why 'ls -ld' doesn't show the link with .files in $HOME, although they show up as links with emelfm.  Is there some other option I should be using?   Also 'du -h' follows the link as well.
« Last Edit: September 24, 2009, 12:29:06 PM by jpeters »

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: listing links (ls -l)
« Reply #1 on: September 25, 2009, 12:57:31 AM »
I don't quite understand what you are asking...but would "ls -lda" work?
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline combo3

  • Full Member
  • ***
  • Posts: 148
Re: listing links (ls -l)
« Reply #2 on: September 25, 2009, 01:24:37 AM »
The -d switch requires extra arguments.

Visible directories: ls -ld */

Hidden directories: ls -ld .*/

All directories: ls -d .*/ */

To list everything, including sudirectories use: ls -laR

To list only links: ls -aR | grep ^l
« Last Edit: September 25, 2009, 02:56:07 AM by combo3 »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: listing links (ls -l)
« Reply #3 on: September 25, 2009, 02:58:57 AM »
Okay, so as combo3 noted,  "ls -lda" or "ls -ld"  needs the extra  ".*" arg, and then correctly lists all the links:

tc@box:~$ ls -lda .*
Code: [Select]
lrwxrwxrwx    1 root     root           35 Sep 24 09:13 .openoffice.org2 -> /mnt/hda3/Desktop/.openoffice.org2//

If I try to list only the .openoffice.org link, however:

tc@box:~$ ls -lda  .openoffice.org2/
Code: [Select]
drwxr-sr-x    3 tc       staff        4096 Sep 24 17:57 .openoffice.org2//

Code: [Select]
tc@box:~$ ls -la .openoffice.org2/
drwxr-sr-x    3 tc       staff        4096 Sep 24 17:57 ./
drwxr-xr-x   14 tc       staff        4096 Sep 24 08:37 ../
drwxr-sr-x   12 tc       staff        4096 Sep 24 08:24 user/

Edit: Interesting....the same goes with "du -h", which requires the ".*" or it follows the link:

du -h
Code: [Select]
2.0M    .openoffice.org2/

du -h .*
Code: [Select]

0       .openoffice.org2

"du -h .openoffice.org2" also follows the link (lists all the files, ending with 2.0M .openoffice.org2/)

Thanks!
« Last Edit: September 25, 2009, 03:23:23 AM by jpeters »

Offline combo3

  • Full Member
  • ***
  • Posts: 148
Re: listing links (ls -l)
« Reply #4 on: September 25, 2009, 03:29:41 AM »
When the argument is a specific directory name, "-d" lists only the directory name.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: listing links (ls -l)
« Reply #5 on: September 25, 2009, 04:17:36 AM »
When the argument is a specific directory name, "-d" lists only the directory name.

It would be nice, however, if  "ld"  showed the link, but at least with ".*" I can see it. Maybe there's  some way to see the individual link, but haven't found it yet.  
« Last Edit: September 25, 2009, 04:39:56 AM by jpeters »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: listing links (ls -l)
« Reply #6 on: September 25, 2009, 04:45:36 AM »
I gues you are playing with the commands provided by Busybox. As an option you can install coreutils to have the "real" tool set. It may behave differently. Did not try with these commands, just an idea.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline combo3

  • Full Member
  • ***
  • Posts: 148
Re: listing links (ls -l)
« Reply #7 on: September 25, 2009, 10:02:45 AM »
It seems the results are dependent on whether your directory name ends with a trailing /

tc@box:~$ ls -lad .boot
lrwxrwxrwx    1 tc       staff          14 Sep 25 08:35 .boot -> /mnt/hda1/boot/

tc@box:~$ ls -lad .boot/
drwxr-xr-x    6 root     root         1024 Sep 22 10:44 .boot//

tc@box:~$ ls -la .boot
lrwxrwxrwx    1 tc       staff          14 Sep 25 08:35 .boot -> /mnt/hda1/boot/

tc@box:~$ ls -la .boot/
drwxr-xr-x    6 root     root         1024 Sep 22 10:44 ./
drwxr-xr-x   10 root     root         1024 Sep 22 10:43 ../
drwxr-xr-x    2 root     root         1024 Sep  8 20:02 grub/
drwxr-xr-x    2 root     root         1024 Sep  2 14:40 tc143/
drwxr-xr-x    2 root     root         1024 Sep  2 09:31 tc220/
drwxr-xr-x    3 root     root         1024 Sep 16 11:15 tc231/

With it, ls displays the contents of the linked directory; without it, you get the contents of the current one.

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: listing links (ls -l)
« Reply #8 on: September 25, 2009, 10:49:40 AM »
It seems the results are dependent on whether your directory name ends with a trailing /

tc@box:~$ ls -lad .boot
lrwxrwxrwx    1 tc       staff          14 Sep 25 08:35 .boot -> /mnt/hda1/boot/

tc@box:~$ ls -lad .boot/
drwxr-xr-x    6 root     root         1024 Sep 22 10:44 .boot//

tc@box:~$ ls -la .boot
lrwxrwxrwx    1 tc       staff          14 Sep 25 08:35 .boot -> /mnt/hda1/boot/

tc@box:~$ ls -la .boot/
drwxr-xr-x    6 root     root         1024 Sep 22 10:44 ./
drwxr-xr-x   10 root     root         1024 Sep 22 10:43 ../
drwxr-xr-x    2 root     root         1024 Sep  8 20:02 grub/
drwxr-xr-x    2 root     root         1024 Sep  2 14:40 tc143/
drwxr-xr-x    2 root     root         1024 Sep  2 09:31 tc220/
drwxr-xr-x    3 root     root         1024 Sep 16 11:15 tc231/

With it, ls displays the contents of the linked directory; without it, you get the contents of the current one.
How is this different than the coreutils ls?
big pc man

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: listing links (ls -l)
« Reply #9 on: September 25, 2009, 11:06:07 AM »
It seems the results are dependent on whether your directory name ends with a trailing /

tc@box:~$ ls -lad .boot
lrwxrwxrwx    1 tc       staff          14 Sep 25 08:35 .boot -> /mnt/hda1/boot/

tc@box:~$ ls -lad .boot/
drwxr-xr-x    6 root     root         1024 Sep 22 10:44 .boot//


ah.......that's it!  Mine automatically includes "/" when I use the tab key to complete it.  
Code: [Select]
tc@box:~$ ls -ld .openoffice.org2/
drwxr-sr-x    3 tc       staff        4096 Sep 24 17:57 .openoffice.org2//
Code: [Select]
tc@box:~$ ls -ld .openoffice.org2
lrwxrwxrwx    1 root     root           35 Sep 25 01:48 .openoffice.org2 -> /mnt/hda3/Desktop/.openoffice.org2//

Thanks for finding this, combo3  ;)

note: "ls -ld" works

bigpcman: When I tried coreutils,  it was doing the same thing. I assume removing the "/" will also work (haven't tried it).  
« Last Edit: September 25, 2009, 01:33:09 PM by jpeters »