- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Listing files links point to
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2007 05:56 AM
09-28-2007 05:56 AM
I want to do ls on a link and have it take it me to the actual file that the link points to.
I found out that /etc has a lot of links that jump from directory to directory, and I just want to see the file they all point to.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2007 06:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2007 06:10 AM
09-28-2007 06:10 AM
Re: Listing files links point to
# perl -MFile::Find -MCwd=realpath -le 'find(sub{print $File::Find::name," -> ",realpath($_) if -l},@ARGV)' /path
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2007 06:11 AM
09-28-2007 06:11 AM
Re: Listing files links point to
I need the file permissions of /sbin/fs_wrapper, not to find out that /etc/newfs is a link, I already know that fact.
: ll /etc/newfs
lrwxr-xr-t 1 root sys 11 Nov 17 2005 /etc/newfs -> /sbin/newfs
baja7:/etc#: ll /sbin/newfs
lrwxr-xr-x 1 bin bin 16 Dec 1 2005 /sbin/newfs -> /sbin/fs_wrapper
baja7:/etc#: ll /sbin/fs_wrapper
-r-xr-xr-x 1 bin bin 647260 May 4 2005 /sbin/fs_wrapper
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2007 06:16 AM
09-28-2007 06:16 AM
Re: Listing files links point to
This is very cool. Seems simple to add another command to ascertain octal permissions of the file in question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2007 06:29 AM
09-28-2007 06:29 AM
Re: Listing files links point to
OK, so you want the permissions of the file to which the link points. Use this:
# cat ./links.pl
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use Cwd qw(realpath);
find(
sub {
printf "%s -> %s [ %04o ]\n", $File::Find::name, realpath($_),
( stat( realpath($_) ) )[2] & 07777
if -l && -e;
},
@ARGV
);
1;
...run, passing the path to interrogate, like:
# ./links.pl /etc
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2007 07:04 AM
09-28-2007 07:04 AM
Re: Listing files links point to
You could do something as simple as:
for link in `ll |grep ^l |awk -F\> '{print $2}'`
do
ll $link
done
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2007 06:01 PM
09-28-2007 06:01 PM
Re: Listing files links point to
But it still has the link name.
You can also see this info by adding a trailing "/":
$ ll /etc/wall
lr-xr-sr-t 1 rootsys 14 Nov 28 2006 /etc/wall@ -> /usr/sbin/wall
$ ll /etc/wall/
-r-xr-sr-x 1 bin tty 16384 Mar 24 2003 /etc/wall/*
$ ll -L /etc/wall
-r-xr-sr-x 1 bin tty 16384 Mar 24 2003 /etc/wall*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2007 08:23 AM
10-05-2007 08:23 AM