Skip to content

Instantly share code, notes, and snippets.

@kumakichi
Created December 19, 2021 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumakichi/68f23c7b47fdd56851b881bae5ab63cb to your computer and use it in GitHub Desktop.
Save kumakichi/68f23c7b47fdd56851b881bae5ab63cb to your computer and use it in GitHub Desktop.
pack direcotry to base64 string && unpack
#!/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"
#!/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