如何使用CLI中的其他命令中的其他命令访问文件
我想在大型文件上使用AWS CLI的一些命令,这些命令存储在S3存储桶中,而无需将文件复制到本地目录 (我熟悉AWS cp 命令,这不是我想要的)。
例如,假设我想使用一个简单的bash命令,例如“ head”或“更多”。 如果我尝试这样使用它:
head s3://bucketname/file.txt
,
但随后我得到:
head:bear s3://bucketname/file.txt'for阅读:没有这样的文件或目录 我还能怎么做?
我还能怎么做?
提前致谢。
I want to use some commands with the aws cli on large files that are stored in a s3 bucket without copying the files to the local directory
(I'm familiar with the aws cp command, it's not what I want).
For example, let's say I want to use a simple bash commands like "head" or "more".
If I try to use it like this:
head s3://bucketname/file.txt
but then I get:
head: cannot open ‘s3://bucketname/file.txt’ for reading: No such file or directory
How else can I do it?
How else can I do it?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
命令是否能够通过S3存储键访问文件是否完全取决于命令。在引擎盖下,每个命令只是一个程序。当您运行
Head FileName
之类的内容时,参数fileName
将作为参数传递给Head Command的Main()函数。您可以在此处查看源代码: https://github.com /coreutils/coreutils/blob/master/src/head.c本质上,由于Head命令不支持S3 URI,因此您无法执行此操作。您可以:
AWS S3 CP Fileanme - |头
。如果文件对于管道缓冲区来说太大,这似乎不是可能的选项。Wether a command will be able to access a file over s3 bucket or not depends entirely on the command. Under the hood, every command is just a program. When you run something like
head filename
, the argumentfilename
is passed as an argument to the head command's main() function. You can check out the source code here: https://github.com/coreutils/coreutils/blob/master/src/head.cEssentially, since the head command does not support S3 URIs, you cannot do this. You can either:
aws s3 cp fileanme - | head
. This doesn't seem the likely option if file is too big for the pipe buffer.