Compress + Base64 encode a (log) file to allow copy via SSH

Sometimes I need to move files from a server on which I have SSH access but these files are big and or have complex formatting which breaks if you just try and copy\paste the contents

So, if we gzip¬† the file then base64 encode this compressed file we now have a string thats much smaller than the original and it’s in a format thats much more conducive to being copied to the clipboard

To compress and encode a file out to stdout

cat file.log | gzip | base64 -w0

To decompress and base64 decode the file

cat file.log.base64 | base64 -d | gunzip > file.log