使用makefile将文件从AWS下载到本地



我想设置一个目标,下载路径中包含_id_config的最新s3文件。所以我知道我可以通过获得我感兴趣的文件名

FILE=$(shell aws s3 ls s3:blah//xyz/mno/here  --recursive | sort | tail -n 2 | awk '{print $4}' | grep id_config)

现在,我想用之类的东西将文件下载到本地

download_stuff:
aws s3 cp s3://prod_an.live.data/$FILE .

但当我运行这个时,我的$FILE有一些额外的东西,比如

aws s3 cp s3://blah/2022-02-17 16:02:21    2098880 blah//xyz/mno/here54fa8c68e41_id_config.json . 
Unknown options: 2098880,blah/xyz/mno/here54fa8c68e41_id_config.json,.

请有人帮我理解为什么输出中有2098880和空格,以及如何解决这个问题。提前谢谢。

建议使用ls选项-1-t来获取文件夹中的最新文件:

FILE=$(shell aws s3 ls -1t s3:blah//xyz/mno/here  |head -n 2 | grep id_config)

最新更新