concatenation - 连接两个 GSUtil 命令
问题描述
我想在一行中执行两个 gsutil 命令,我该如何实现。例如:
gsutil ls gs://projectname/bucketname/folder1/folder2/filename.png | \
cp gs://projectname/bucketname/folder3/folder4/
从特定存储桶中查找/列出文件并将同一文件复制到存储桶文件夹。在上面的命令中,我使用的是 ls (列表)和 cp (复制)命令,但这没有按预期工作。
类似于下面的 shell 脚本或 linux 命令,我们使用 exec 并继续执行下一个命令。
find -type f -path '*schedule*/*' -name "*.png" -exec cp -n {} /tmp/MusicFiles \;
非常感谢您的早期回复。提前致谢..!
解决方案
Oneliner:来自gsutil help cp
:
-I Causes gsutil to read the list of files or objects to copy from
stdin. This allows you to run a program that generates the list
of files to upload/download.
所以,some_program | gsutil -m cp -I gs://my-bucket
。
一些程序可以在哪里gsutil ls ...
此外,
gsutil 接受通配符,因此该命令将是这样的。
gsutul cp gs:/bucket-name/*schedule*/*/*.png gs://bucketname/folder3/folder4/
请注意,递归通配符可以使用单星*
和双星**
。
推荐阅读
- kubernetes - 从 pod 访问入口 IP
- node.js - 从 Microsoft graph api 列出用户所需的权限
- kubernetes - Kubernetes 集群中的请求缓冲
- asp.net - 403 禁止访问在 IIS 上托管的 asp.net 网站上使用 ssl 的图像被拒绝
- python - 将直方图箱添加在一起并绘制图形
- maven - Maven 插件中与 Eclipse Sisu/Guice 的自定义绑定
- python - tkinter 中的 scroll_text.insert 在程序完成后运行
- python - QTreeView/QFileSystemModel - 比较文件和显示颜色
- javascript - 在css中将图像url作为背景导入时出现Webpack错误
- javascript - 如何在使用 .map() 呈现的按钮之间切换 CSS 类