Skip to main content
replaced http://askubuntu.com/ with https://askubuntu.com/
Source Link

Let me give an example (it's just an example taken from herehere):

$ ls -l /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor $ ls -l /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit $ ls -l /usr/bin/gedit -rwxr-xr-x 1 root root 588064 Mar 27 2014 /usr/bin/gedit 

Here you can see that I've to use ls -l three times for reaching to destination. (3rd time is for making sure that /usr/bin/gedit is not a link`)

Is there any way (by means of making script or another command etc.) that I can get expected output like:

$ <improved ls -l> /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit 

Another good output may be:

$ <some-command> /usr/bin/gnome-text-editor /usr/bin/gnome-text-editor > /etc/alternatives/gnome-text-editor > /usr/bin/gedit 

Let me give an example (it's just an example taken from here):

$ ls -l /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor $ ls -l /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit $ ls -l /usr/bin/gedit -rwxr-xr-x 1 root root 588064 Mar 27 2014 /usr/bin/gedit 

Here you can see that I've to use ls -l three times for reaching to destination. (3rd time is for making sure that /usr/bin/gedit is not a link`)

Is there any way (by means of making script or another command etc.) that I can get expected output like:

$ <improved ls -l> /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit 

Another good output may be:

$ <some-command> /usr/bin/gnome-text-editor /usr/bin/gnome-text-editor > /etc/alternatives/gnome-text-editor > /usr/bin/gedit 

Let me give an example (it's just an example taken from here):

$ ls -l /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor $ ls -l /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit $ ls -l /usr/bin/gedit -rwxr-xr-x 1 root root 588064 Mar 27 2014 /usr/bin/gedit 

Here you can see that I've to use ls -l three times for reaching to destination. (3rd time is for making sure that /usr/bin/gedit is not a link`)

Is there any way (by means of making script or another command etc.) that I can get expected output like:

$ <improved ls -l> /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit 

Another good output may be:

$ <some-command> /usr/bin/gnome-text-editor /usr/bin/gnome-text-editor > /etc/alternatives/gnome-text-editor > /usr/bin/gedit 
Tweeted twitter.com/StackUnix/status/712071992032235520
added 173 characters in body
Source Link
Pandya
  • 25.8k
  • 31
  • 99
  • 147

Let me give an example (it's just an example taken from here):

$ ls -l /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor $ ls -l /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit $ ls -l /usr/bin/gedit -rwxr-xr-x 1 root root 588064 Mar 27 2014 /usr/bin/gedit 

Here you can see that I've to use ls -l three times for reaching to destination. (3rd time is for making sure that /usr/bin/gedit is not a link`)

Is there any way (by means of making script or another command etc.) that I can get expected output like:

$ <improved ls -l> /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit 

Another good output may be:

$ <some-command> /usr/bin/gnome-text-editor /usr/bin/gnome-text-editor > /etc/alternatives/gnome-text-editor > /usr/bin/gedit 

Let me give an example (it's just an example taken from here):

$ ls -l /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor $ ls -l /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit $ ls -l /usr/bin/gedit -rwxr-xr-x 1 root root 588064 Mar 27 2014 /usr/bin/gedit 

Here you can see that I've to use ls -l three times for reaching to destination. (3rd time is for making sure that /usr/bin/gedit is not a link`)

Is there any way (by means of making script or another command etc.) that I can get expected output like:

$ <improved ls -l> /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit 

Let me give an example (it's just an example taken from here):

$ ls -l /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor $ ls -l /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit $ ls -l /usr/bin/gedit -rwxr-xr-x 1 root root 588064 Mar 27 2014 /usr/bin/gedit 

Here you can see that I've to use ls -l three times for reaching to destination. (3rd time is for making sure that /usr/bin/gedit is not a link`)

Is there any way (by means of making script or another command etc.) that I can get expected output like:

$ <improved ls -l> /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit 

Another good output may be:

$ <some-command> /usr/bin/gnome-text-editor /usr/bin/gnome-text-editor > /etc/alternatives/gnome-text-editor > /usr/bin/gedit 
Source Link
Pandya
  • 25.8k
  • 31
  • 99
  • 147

How do I get `ls -l` output for a link recursively until reached the original file?

Let me give an example (it's just an example taken from here):

$ ls -l /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor $ ls -l /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit $ ls -l /usr/bin/gedit -rwxr-xr-x 1 root root 588064 Mar 27 2014 /usr/bin/gedit 

Here you can see that I've to use ls -l three times for reaching to destination. (3rd time is for making sure that /usr/bin/gedit is not a link`)

Is there any way (by means of making script or another command etc.) that I can get expected output like:

$ <improved ls -l> /usr/bin/gnome-text-editor lrwxrwxrwx 1 root root 35 Mar 16 2015 /usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor lrwxrwxrwx 1 root root 14 Mar 16 2015 /etc/alternatives/gnome-text-editor -> /usr/bin/gedit