我该如何选择创建Linux的其他目录的符号链接到特定的文件? [英] How do I selectively create symbolic links to specific files in another directory in LINUX?

查看:267
本文介绍了我该如何选择创建Linux的其他目录的符号链接到特定的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不完全知道如何去这样做,但我需要创建某些文件的符号链接在一个目录中,并放在其他目录下的符号链接。

I'm not exactly sure how to go about doing this, but I need to create symbolic links for certain files in one directory and place the symbolic links in another directory.

比如说,我想所有的文件,在当前目录BAR1不具有扩展名.CC,并放置符号链接的目录BAR2在其名称中的单词foo的链接。

For instance, I want to link all files with the word "foo" in its name in the current directory bar1 that does not have the extension ".cc" and place the symbolic links in a directory bar2.

我在想,如果有一行命令,可以在LINUX bash中做到这一点。

I was wondering if there was single line command that could accomplish this in LINUX bash.

推荐答案

假设你是在包含目录的目录 BAR1 BAR2

Assuming you are in a directory that contains directories bar1 and bar2:

find bar1 -name '*foo*' -not -type d -not -name '*.cc' -exec ln -s $PWD/'{}' bar2/ \;

这篇关于我该如何选择创建Linux的其他目录的符号链接到特定的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆