1
I have this output from a s3cmd ls --list-md5
command.
2013-05-22 12:20 1965154 41eae9b40d23de2f02bf07635870f6d0 s3://company-backup/company/amazon/ip-11-11-111-11/backup_server245/app.20121117040001.gz
2013-05-22 12:20 11456836 541b1bf78682f48867cc99dbb53c4c3a s3://company-backup/company/amazon/ip-11-11-111-11/backup_server245/app.20121118040001.gz
..
I'm trying to verify if the md5sum
from my object in the bucket match with my md5sum
in my local machine. So for that I need to get the hash
result as the fourth
column and the filename as the fifth
column.
Like that:
41eae9b40d23de2f02bf07635870f6d0 s3://company-backup/company/amazon/ip-11-11-111-11/backup_server245/app.20121117040001.gz
But I need only the filename, so for that I'm using the basename
command (I just don't know how to use it here yet but I will figure out), at the end is looking like this:
s3=`s3cmd ls --list-md5 s3://company-backup/company/amazon/ip-11-11-111-11/backup_server245/`;
echo "$s3";
echo "$s3" | tr -s ' ' | cut -d ' ' -f 4;
echo "$s3" | tr -s ' ' | cut -d ' ' -f 5;
Now I need to store the result from the echo's
at the same variable like these:
41eae9b40d23de2f02bf07635870f6d0 app.20121117040001.gz
So I could compare the results from s3cmd ls --list-md5sum
with my md5sum *.gz
running locally.
update Using the diff approach my command looks like:
ls --list-md5 s3://company-backup/company/amazon/ip-11-11-111-11/backup/server245/ \
| tr -s ' ' \
| cut -d ' ' -f 4,5 \
| sed 's= .*/= =' \
| diff -w - <(md5sum /backup/server245/*.gz)
Giving the follow result:
1,50c1,49
< d41d8cd98f00b204e9800998ecf8427e
< 41eae9b40d23de2f02bf07635870f6d0 app.20121117040001.gz
< 541b1bf78682f48867cc99dbb53c4c3a app.20121118040001.gz
..
---
> 41eae9b40d23de2f02bf07635870f6d0 /backup/diveo245/app.20121117040001.gz
> 541b1bf78682f48867cc99dbb53c4c3a /backup/diveo245/app.20121118040001.gz
..
But how to know the file that is different then ? ('cause all that are equal I can delete alredy)
1can't you just
Var=$(echo....)
? – demure – 2013-05-22T13:51:27.283