- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Determine soft link directory
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
02-18-2004 09:10 PM
02-18-2004 09:10 PM
Determine soft link directory
I have a soft link pointing from /A/B/C-> D.
I execute the command cd /A/B/C to login to directory D.
If I execute the dirname /A/B/C I get the o/p as /A/B. But the requirement that I need is the actually location of D.
Is there any simple way of doing this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 09:19 PM
02-18-2004 09:19 PM
Re: Determine soft link directory
# cd /a/b/c
This will now point to temp/d
Here c is link which points to /temp/d
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 09:37 PM
02-18-2004 09:37 PM
Re: Determine soft link directory
So to get what you need I afraid you have to give $dirname /temp/D only.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 09:59 PM
02-18-2004 09:59 PM
Re: Determine soft link directory
In the script I have a default location: /A/B/C. The user has the option of creating a directory /temp/D. If this done from the default there is a softlink pointing to the non-default.
Now the script recognizes only the default and not the non default. I need to get the softlink path so that I populate the parent directory of the softlink i.e. /temp directory.
One option is do a ll -ls -> grep "directory" -> awk NF to get the exact path of the soft link and then do dirname path
But the above is cumbersome and is round about method. Is there any faster method of accessing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 10:07 PM
02-18-2004 10:07 PM
Re: Determine soft link directory
lt09:/tmp 106 > perl -le'print readlink for @ARGV' D
/A/B/D
lt09:/tmp 107 >
This does *NOT* guarantee that the target folder does exist. It is still a symbolic link
lt09:/tmp 107 > ln -s /usr/tmp E
lt09:/tmp 108 > perl -MCwd -le'print Cwd::realpath $_ for @ARGV' D E
/var/tmp
lt09:/tmp 109 >
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 10:08 PM
02-18-2004 10:08 PM
Re: Determine soft link directory
You can use pwd for dir that includes softlink dir and /bin/pwd for real location.
HTH,
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2004 11:14 PM
02-18-2004 11:14 PM
Re: Determine soft link directory
I tried doing a pwd on /A/B/C. The output is /A/B/C and not what I wanted i.e. the location D.
Please let me know in case I have misunderstood the explaination.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 01:11 AM
02-19-2004 01:11 AM
Re: Determine soft link directory
Previous tip should work :
$ ls -l SdDD
lrwxr-xr-x 1 phelix CST 12 Feb 22 2003 SdDD -> /homeHA/SdDD
$ A=$(cd SdDD ; pwd)
$ B=$(dirname $(cd SdDD ; pwd))
$ echo $A $B
/homeHA/phelix/SdDD /homeHA/phelix
$ A=$(cd SdDD ; /usr/bin/pwd)
$ B=$(dirname $(cd SdDD ; /usr/bin/pwd))
$ echo $A $B
/homeHA/SdDD /homeHA
The only problem is if the target sym link doesn't exist ...
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2004 01:19 AM
02-19-2004 01:19 AM