Linux shell / ESXi – scripts to get md5sum for sets of files in sorted and regular order
Posted by jpluimers on 2019/05/08
A few small scripts without any parameter checking are below.
The are based on these links:
- [Archive.is] linux – How to store and echo multiple lines elegantly in bash? – Stack Overflow
- [WayBack] Capturing multiple line output into a Bash variable – Stack Overflow (which I just found out I mentioned inSource: Getting your local IPv4 addresses, netmasks and CIDRs)
find-in-datastores.sh
#!/bin/sh # Notes: # the "find" parameter "-type l" only links, as they are the datastore aliases # the "sed" appends a slash to all datastore paths datastores_slashes=`find /vmfs/volumes/* -prune -type l | sed 's/$/\//' | xargs echo` # find inside the datatastores with the arguments appended: find $datastores_slashes $@
md5sum-sorted-and-regular.sh:
#!/bin/sh md5sums=`md5sum $@` echo Regular: echo "$md5sums" echo Sorted: echo "$md5sums" | sort
md5sum-of-find-in-datastores-by-name-sorted-and-regular.sh :
#!/bin/sh md5sum-sorted-and-regular.sh `find-in-datastores.sh -name $@`
Example usage:
# md5sum-of-find-in-datastores-by-name-sorted-and-regular.sh EN-10ENT-x64.vmx Regular: 7f34fbceed59957a4b7feb13ef9327a1 /vmfs/volumes/Samsung512NVME/PSO.Template/VM/EN-10ENT-x64/EN-10ENT-x64.vmx 7f34fbceed59957a4b7feb13ef9327a1 /vmfs/volumes/Samsung850-2TB-S2KMNCAGB04321L/PSO.Inactive/VM/EN-10ENT-x64/EN-10ENT-x64.vmx 7f34fbceed59957a4b7feb13ef9327a1 /vmfs/volumes/Samsung850-2TB-S3D4NX0HA01043L/PSO.Inactive/VM/EN-10ENT-x64/EN-10ENT-x64.vmx Sorted: 7f34fbceed59957a4b7feb13ef9327a1 /vmfs/volumes/Samsung512NVME/PSO.Template/VM/EN-10ENT-x64/EN-10ENT-x64.vmx 7f34fbceed59957a4b7feb13ef9327a1 /vmfs/volumes/Samsung850-2TB-S2KMNCAGB04321L/PSO.Inactive/VM/EN-10ENT-x64/EN-10ENT-x64.vmx 7f34fbceed59957a4b7feb13ef9327a1 /vmfs/volumes/Samsung850-2TB-S3D4NX0HA01043L/PSO.Inactive/VM/EN-10ENT-x64/EN-10ENT-x64.vmx
–jeroen






Leave a comment