2016-01-21 42 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...

相關問題