简体   繁体   English

需要使用 shell 脚本从 azure 中的 blob 存储中获取文件名

[英]Need to get the filename from a blob storage in azure using shell script

I am trying to fetch the filename in a blob storage so as to use it in my script further.我试图在 blob 存储中获取文件名,以便在我的脚本中进一步使用它。 I tried using az storage blob list and list the blobs present there, but unsuccessful to.我尝试使用 az storage blob list 并列出那里存在的 blob,但没有成功。

Here's the command that I used:这是我使用的命令:

az storage blob list --connection-string connstr --container-name "vinny/input/"

It threw error as The requested URI does not represent any resource on the server.ErrorCode: InvalidUri它抛出错误,因为请求的 URI 不代表服务器上的任何资源。ErrorCode: InvalidUri

Seems like it would just take the container and not the folder in it.似乎它只会占用容器而不是其中的文件夹。 But when i tried:但是当我尝试时:

az storage blob list --connection-string connstr --container-name "vinny"

It doesn't list the file but keeps on executing.它没有列出文件,而是继续执行。

I need to get the filename that's inside vinny/input/我需要获取 vinny/input/ 中的文件名

Anyone got any solution for it?任何人有任何解决方案吗?

I just added a --prefix option to it and was able to list the file the way I wanted.我刚刚添加了一个 --prefix 选项,并且能够按照我想要的方式列出文件。 Here it goes:它是这样的:

az storage blob list --connection-string connstr --container-name "vinny" --prefix "Input/" --output table
cli> az storage blob list -c container_name  --account-name storage_accaunt_name --output=table --num-results=* | awk or cut 

then you can parse txt file with awk and cut etc..然后你可以用awk和cut等解析txt文件。

good luck祝你好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 bash 脚本从 Azure Blob 存储读取 JSON 文件并写回 Blob 存储中的另一个文件 - Read JSON file from Azure Blob Storage using bash script and write back to another file in blob storage 如何从子目录提取文件名和路径,并需要使用unix shell脚本将输出写入到csv文件中 - How to extract the filename and path from sub directories and need to write the output into a csv file using unix shell script 使用 Bash/Curl 从 Azure Blob Storage 下载文件 - Download a file from Azure Blob Storage using Bash/Curl 使用Shell脚本从文件名重命名特定的字符串 - Rename specific string from filename using shell script 使用bash,curl访问Azure blob存储 - Accessing Azure blob storage using bash, curl 正则表达式使用文件名外壳脚本过滤文件 - regex to filter files using filename shell script 如何从Shell脚本中的旧文件名获取新文件名? - How to obtain new filename from old filename in the shell script? 如何检索使用从 python 脚本调用的 shell 脚本创建的文件名和文件? - How to retrieve a filename and file created using a shell script that was called from a python script? 需要使用Shell脚本替换文件中的特定行 - Need to replace a specific part of line from a file using shell script 需要使用 Shell 脚本从目录中选择最新文件 - Need to pick Latest File From a Dir Using Shell Script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM