Created
December 19, 2021 11:58
-
-
Save kumakichi/68f23c7b47fdd56851b881bae5ab63cb to your computer and use it in GitHub Desktop.
pack direcotry to base64 string && unpack
This file contains hidden or 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 | |
delim="#" | |
dirname=$(echo ${PWD##*/}) | |
outname="${dirname}.tar.bz2" | |
tar cjf "$outname" * | |
base64Str=$(base64 "$outname" | tr -d '\n') | |
rm $outname | |
echo "${dirname}${delim}$base64Str" |
This file contains hidden or 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 | |
if [ $# -ne 1 ] | |
then | |
echo "Usage: $0 str" | |
exit | |
fi | |
delim="#" | |
tmpFile="tmp.san.str2dir.tar.bz2" | |
str="$1" | |
dirname="$(echo $str | awk -F"$delim" '{print $1}')" | |
hashStr=$(echo $str | awk -F"$delim" '{print $2}') | |
mkdir "$dirname" | |
cd "$dirname" | |
echo -ne $hashStr | base64 -d > $tmpFile | |
tar xf $tmpFile | |
rm -rf $tmpFile | |
echo "decompressed files in directory '$dirname'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment