gpt4 book ai didi

linux - 如何在 Linux bash shell 脚本的 curl 命令中使用变量来发送带有文件的 post 请求?

转载 作者:太空宇宙 更新时间:2023-11-04 10:18:57 27 4
gpt4 key购买 nike

例如。我可以在终端中成功执行以下命令:

curl -sX POST -F 'file=@/tmp/test.tgz' -F 'fileName=test.tgz' http://localhost:8080/upload

但是,如果我在bash shell脚本中将文件路径str "/tmp/test.tgz"替换为一个变量,那么它就不行了,请问你能帮忙告诉我如何解决吗?

curl -sX POST -F 'file=@$myfile' -F 'fileName=test.tgz' http://localhost:8080/upload

最佳答案

如果要变量扩展,请使用 "而不是 '

关于linux - 如何在 Linux bash shell 脚本的 curl 命令中使用变量来发送带有文件的 post 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44733378/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com