2016-01-21 45 views
0

我正在使用以下命令列出系统上的所有符号链接。如何在Unix系统中找到所有符号链接的绝对路径

ls -lR . | grep ^l > /usr/local/docato-composer/all-sym-links.txt 

从输出

lrwxrwxrwx 1 root  root   12 Jul 19 2010 sd3d -> dsk/c0t0d0s3 

我们移植我们的应用程序到一个专用的服务器,所以我需要让所有的符号链接,然后手动查找特定于重建他们的应用程序的那些取出的一行在新的服务器中。如何使用绝对路径(/ folder1/folder2/sd3d而不是sd3d)列出系统上的所有符号链接?

+0

您正在将Docato实例迁移到新服务器?你很勇敢。但是Docato是[商业软件](https://www.flatironssolutions.com/news/flatirons-solutions-enters-into-exclusive-support-agreement-with-emc-for-docato-component-services-solution/)。通过商业渠道提供支持,不是吗?您是否考虑过花费时间和精力来完成此基础架构迁移,而不是迁移到新的(并且支持更好的)CMS?在开源世界中有许多伟大的选择。 – ghoti

回答

2

我认为find . -type l -ls是您正在查找的命令。 (您可能需要修剪出来的/ proc文件系统等)

样本输出(略编辑,以使其适合)的提取物:

678 0 lrwxrwxrwx 1 root root  6 Oct 25 2014 /bin/open -> openvt 
    141 0 lrwxrwxrwx 1 root root  8 Feb 26 2015 /bin/ypdomainname -> hostname 
    153 0 lrwxrwxrwx 1 root root  20 Feb 26 2015 /bin/mt -> /etc/alternatives/mt 
    155 0 lrwxrwxrwx 1 root root  4 Feb 26 2015 /bin/sh.distrib -> dash 
    5568 0 lrwxrwxrwx 1 root root  14 Apr 6 2015 /bin/pidof -> /sbin/killall5 
0

我会做这样的事情:

find . -type l -printf "\r\n%p -> %l" 

当然,您可以使用您需要的任何分隔符而不是->

0
下面

显示了在当前目录下符号链接,递归,但没有跟着他们,显示的全路径和其他信息:

find ./ -type l -print0 | xargs -0 ls -plah

输出看起来大约是这样的:

lrwxrwxrwx 1 apache develop 99 Dec 5 12:49 ./dir/dir2/symlink1 -> /dir3/symlinkTarget lrwxrwxrwx 1 apache develop 81 Jan 10 14:02 ./dir1/dir2/dir4/symlink2 -> /dir5/whatever/symlink2Target etc...

相关问题