Bash-如何将文件引用为变量?

Bash-如何将文件引用为变量?,bash,Bash,我正在使用脚本生成一个附加了当前日期的文件,然后将该文件导出到AmazonS3。剧本是: #!/bin/bash #python script that exports file in the form of "myfile{current date}.csv" to home directory #example: myfile20150316.csv python some_script.py #recreate file name exported by some_script.py

我正在使用脚本生成一个附加了当前日期的文件,然后将该文件导出到AmazonS3。剧本是:

#!/bin/bash

#python script that exports file in the form of "myfile{current date}.csv" to home directory
#example: myfile20150316.csv
python some_script.py

#recreate file name exported by some_script.py and save as a variable
now=$(date "+%Y%m%d")
file_name="myfile"
file_ext=".csv"
_file="$file_name$now$file_ext"

#export to file created by python to S3
s3cmd put $_file S3://myS3/bucket/$_file
该文件由python脚本创建并导出到my home目录,但该文件不会导出到S3。我的假设是,我在
s3cmd
命令中错误地引用了该文件

这不是一个S3问题。在一般意义上,我应该如何引用包含文件名的变量,以便能够在后续命令中使用它们


请帮忙。谢谢。

这看起来不错,但我不知道
s3cmd
command这里到底出了什么问题?
s3cmd
是否无法放置文件?python脚本是否在当前目录以外的其他目录中创建文件?看起来您缺少将文件名与文件扩展名分开的“点”。如果是我,我会让python脚本打印出它创建的文件名,然后捕获它,这样您就不必重新创建文件名:
file=“$(python myscript.py)”
@Etan-python脚本工作正常,它将文件写入主目录。我使用了
s3cmd
命令手动将文件放入S3。我只是想在bash脚本中运行cron。@nathan-我正在使用
文件\u ext=“.csv”
作为文件扩展名。点在那里,除非你指的是其他东西。