2

I want to execute the find command but I want it to return the target instead of the symbolic link itselft.

Is that possible to do in HP-UX?

For example, with:

security -> /dev/vg_irp_ist/rlv_IRP1_security

I want to return /dev/vg_irp_ist/rlv_IRP1_security and not security.

j0k
  • 22,600
  • 28
  • 79
  • 90
aF.
  • 64,980
  • 43
  • 135
  • 198

1 Answers1

3
#!/bin/ksh
 name=$(find /path/to/dir -type l -name whatever -exec ls -l {} \; |awk -F '>' '{print $2}')

HPUX does not have a readlink command. If you have GNU coreutils installed then use readlink. Otherwise you are stuck with the above.

This is the backwrds version - given the actual filename look thru links to find it. BEWARE of relative paths in links: i.e., ../../foo/filename

export filename="xz.exe"
find . -type l -exec ls -l {} \; | 
     awk '{print $(NF)}') | grep -q "$filename" && echo $val
jim mcnamara
  • 16,005
  • 2
  • 34
  • 51
  • I want to find by the name of the target of the symbolic link and not by the name of the symbolic link itself, do you know how can I change that? – aF. Mar 26 '13 at 13:26