【发布时间】:2014-12-10 13:00:59
【问题描述】:
我有以下 bash 脚本:
s3upload() {
n=$1
extension=`file $n | cut -d ' ' -f2 | awk '{print tolower($0)}'`
mimetype=`file --mime-type $n | cut -d ' ' -f2`
fullpath=`readlink -f $n`
expires="Expires:`date -u +"%a, %d %b %Y %H:%M:%S GMT" --date "+1 years"`"
cache='Cache-Control:max-age=1296000, public'
s3upload="s3cmd put -vvv --recursive setacl --acl-public --add-header $expires --add-header $cache -m $mimetype $fullpath s3://ccc-public/catalog/"
response=`$s3upload`
echo $response
}
export -f s3upload
find nas/cdn/catalog/drawings/ \( ! -regex '.*/\..*' \) -type f | s3upload
当我执行它时,文件名不会被返回!
我喜欢让脚本检查每个文件的 mime-type 并设置过期和缓存。
如果我运行find nas/cdn/catalog/drawings/ \( ! -regex '.*/\..*' \) -type f,这将起作用并返回:
nas/cdn/catalog/drawings/N16.jpg
nas/cdn/catalog/drawings/EPB01.jpg
nas/cdn/catalog/drawings/N80.jpg
nas/cdn/catalog/drawings/EP22.jpg
nas/cdn/catalog/drawings/N95.jpg
非常感谢任何建议。
【问题讨论】: