Frage

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.

War es hilfreich?

Lösung

#!/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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top