md5sum

通过MD5值,来判断自己down的文件与服务器上的文件是否一致。也可以比较两个文件是否相同。

1.在mac上运行:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

此进输入brew就可以运行了。

2.运行:

brew install md5sha1sum

3.通过运行 md5sum xxxxx.yy的方式,就可以看到此文件的md5值。

mac下获取文件的md5与sha1值

MD5Str = 'echo -n $str|md5sum'

echo -n 'admin' | md5sum
輸出21232f297a57a5a743894a0e4a801fc3

shell脚本获取当前时间戳

current=date "+%Y-%m-%d %H:%M:%S"
timeStamp=date -d "$current" +%s

将current转换为时间戳,精确到毫秒

currentTimeStamp=((timeStamp*1000+`date "+%N"`/1000000)) echocurrentTimeStamp

执行.sh文件
chmod 777 1.sh
./updateapp.sh

current=date +%s
echo $current

str="abc"
echo {str} echo -n abc|md5sum echo -n 'abc'|md5sum|cut -d ' ' -f1 echo -n{str}|md5sum|cut -d ' ' -f1

linux在shell中执行命令并将结果赋值给变量

经过验证如下:
date=$(command)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容