开发者

Need help listing symbolic links

开发者 https://www.devze.com 2023-03-31 10:42 出处:网络
On a Unix/Linux system I need to run the \"find\" command on a set of directories to find what all the symbolic links within those directories are.I need to get a list 开发者_Go百科of the symbolic lin

On a Unix/Linux system I need to run the "find" command on a set of directories to find what all the symbolic links within those directories are. I need to get a list 开发者_Go百科of the symbolic link paths in one file AND a list of the output of "ls -l" on those symbolic links in another file. How can I do this?


Change to the directory in question, then:

$ find -type l > /tmp/link_names.txt

$ (for link in $(cat /tmp/output.txt); do ls -l "$link"; done) > /tmp/link_details.txt

Warning: if any of the paths contain spaces you'll have to use something like this to get the "ls -l" output:

$ find -type l | -print0 | xargs -0 ls -l > /tmp/link_details.txt
0

精彩评论

暂无评论...
验证码 换一张
取 消