Created
June 13, 2020 03:36
-
-
Save skurscheid/b3917e666ed608b47d4c28021494f272 to your computer and use it in GitHub Desktop.
Bash function to generate TAR file of a directory with MD5 checksums of included fly; can be used in conjunction with ls | xargs -n1 -I% bash -c 'tar_md5 "$*"' _ % to loop over directory contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function tar_md5 { | |
DIR=${1} | |
if [[ -d $DIR ]] | |
then | |
tar -cvpf ${DIR}.tar ${DIR}/| xargs -I '{}' sh -c "test -f '{}' && md5sum '{}'" | tee ${DIR}.md5 | |
fi | |
} | |
export -f tar_md5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment