Jekyll 在使用gsutil进行rsync时,如何排除隐藏的文件和目录?

Jekyll 在使用gsutil进行rsync时,如何排除隐藏的文件和目录?,jekyll,google-cloud-storage,google-cloud-platform,gsutil,Jekyll,Google Cloud Storage,Google Cloud Platform,Gsutil,我有一个目录结构的Jekyll博客,其中包含许多隐藏的文件和目录,如.DS_Store、.idea和.git。它还有中间构建工件和脚本,它们以\uu开头,比如\u deploy.sh和\u drafts 我想写一个脚本,将所有东西上传到谷歌云存储的一个存储桶中,除了这些隐藏的文件和带下划线的工件 我尝试使用-x标志,但我的表达式要么排除整个当前目录,什么也不上载,要么排除我想要排除的某些内容失败 以下是我目前掌握的情况: #!/bin/sh gsutil -m rsync -rx '\..*|.

我有一个目录结构的Jekyll博客,其中包含许多隐藏的文件和目录,如
.DS_Store
.idea
.git
。它还有中间构建工件和脚本,它们以
\uu
开头,比如
\u deploy.sh
\u drafts

我想写一个脚本,将所有东西上传到谷歌云存储的一个存储桶中,除了这些隐藏的文件和带下划线的工件

我尝试使用
-x
标志,但我的表达式要么排除整个当前目录,什么也不上载,要么排除我想要排除的某些内容失败

以下是我目前掌握的情况:

#!/bin/sh
gsutil -m rsync -rx '\..*|./[.].*$|_*' ./ gs://my-bucket.com/path
我观察到的结果是:

$  ./_deployblog.sh
Building synchronization state...
Starting synchronization

一系列真正特定的正则表达式解决了这个问题:

gsutil -m rsync -rdx '\..*|.*/\.[^/]*$|.*/\..*/.*$|_.*' . gs://my-bucket.com/path
其中排除模式有4个由
|
字符分隔的组件

\..*        <- excludes .files and .directories in the current directory
.*/\.[^/]*$ <- excludes .files in subdirectories
.*/\..*/.*$ <- excludes .directories in subdirectories
_.*         <- excludes _files and _directories

\.*一系列真正特定的正则表达式解决了这个问题:

gsutil -m rsync -rdx '\..*|.*/\.[^/]*$|.*/\..*/.*$|_.*' . gs://my-bucket.com/path
其中排除模式有4个由
|
字符分隔的组件

\..*        <- excludes .files and .directories in the current directory
.*/\.[^/]*$ <- excludes .files in subdirectories
.*/\..*/.*$ <- excludes .directories in subdirectories
_.*         <- excludes _files and _directories
\*