【问题标题】:How do I get list of paths that exclude certain subdirectories如何获取排除某些子目录的路径列表
【发布时间】:2021-08-19 07:56:34
【问题描述】:

我想使用 rclone 将我的所有项目复制到谷歌驱动器,但我不想复制 node_modules 等目录中的文件, 例子: 根:项目 子目录:myBlog/node_modules/、myBlog/backend/node_modules。 我是 Linux 的初学者,所以不知道如何使用 find、grep 等来实现。

【问题讨论】:

标签: linux grep ls


【解决方案1】:

你问了两个问题。

  1. 如何列出排除某些子目录的路径
  2. 使用rclone时如何排除某些子目录

上市

使用find 命令。这是一个包含三个子目录的示例目录:

ls

one two three

要输出仅包含 onetwo 的列表,省略 three,请像这样使用 find

find . -type d -not -path ./two
.
./one
./three

rclone

使用--exclude 开关,排除特定子目录的内容 - 在本例中,子目录two(在stackoverflow 下方)将在同步到destination 时被省略:

rclone sync stackoverflow/ destination/ --exclude='two/**'

更多详情请参阅rclonedocumentation

【讨论】:

    猜你喜欢
    • 2015-03-17
    • 1970-01-01
    • 2016-03-14
    • 1970-01-01
    • 2021-04-08
    • 1970-01-01
    • 1970-01-01
    • 2014-01-07
    • 2017-03-05
    相关资源
    最近更新 更多