Hi all,
Can anyone please confirm if the command below is the only way that I can get what the symbolic link is set to?
mnlxd110(oracle)[posd2]/db/posd2/dba$: ls -l | grep "^l"
lrwxrwxrwx 1 oracle dba 28 Aug 9 2011 bdump -> diag/rdbms/posp1/posp1/trace
mnlxd110(oracle)[posd2]/db/posd2/dba$: ls -l | grep "^l" | awk '{ print $11 }'
diag/rdbms/posp1/posp1/trace
mnlxd110(oracle)[posd2]/db/posd2/dba$:
Is there any way to run some sort of ls -1 that will do the same thing as above?
Feedback much appreciated. Thanks in advance.
hergp
August 30, 2012, 2:28am
2
You can combine grep and awk into one awk statement and optimize for different column counts in ls -l:
ls -l | awk '$1 ~ /^l/ { print $NF }'
or you could use find with readlink (assuming you have readlink installed):
find . -type l -exec readlink {} \;
1 Like
RudiC
August 30, 2012, 3:17am
3
If available on your system, try
stat -c "%F %N"
Hi,
Thanks for your reply, unfortunately, got no stat. the suggestion from hergp seems to the best solution, making use of NF, got no readlink as well :(-
"readlink" would be the alias/scriptname you give to his "ls ... | awk ..." line. Either turn this line into a script (filename would be in "$1") /along/your/$PATH/readlink and flag it executable or define an alias:
alias readlink='ls....'
I hope this helps.
bakunin
priyak:
Hi,
Try below command too
ll | cut -f2 -d">"
And what is ll
? I assume it's an alias for long listing. But, not everybody will have it set, right?
priyak
August 30, 2012, 9:17am
8
Hi,
ll is an alias in most Linux distributions that stands for: $ls -l