我想实现这个作为一个Makefile任务:但是如何在Makefile中获取Unix上的文件大小?
# step 1:
curl -u username:password -X POST \
-d '{"name": "new_file.jpg","size": 114034,"description": "Latest release","content_type": "text/plain"}' \
https://api.github.com/repos/:user/:repo/downloads
# step 2:
curl -u username:password \
-F "key=downloads/octocat/Hello-World/new_file.jpg" \
-F "acl=public-read" \
-F "success_action_status=201" \
-F "Filename=new_file.jpg" \
-F "AWSAccessKeyId=1ABCDEF..." \
-F "Policy=ewogIC..." \
-F "Signature=mwnF..." \
-F "Content-Type=image/jpeg" \
-F "[email protected]_file.jpg" \
https://github.s3.amazonaws.com/
在第一部分中,我需要得到的文件大小(和内容类型,如果它很容易,不需要虽然),所以一些变量:
{"name": "new_file.jpg","size": $(FILE_SIZE),"description": "Latest release","content_type": "text/plain"}
我试过,但它不工作(苹果机10.6.7):
$(shell du path/to/file.js | awk '{print $1}')
任何想法如何做到这一点?
你需要以字节为单位的大小吗? GNU coreutils'du'命令有一个'-b'选项来执行此操作; [MacOS du](http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/du.1.html)显然没有。小心不要意外地给'du'输入一个目录名称。 –