#!/bin/awk -f ## from https://www.opennet.ru/base/dev/awk_base64.txt.html BEGIN{n["/"]=63;n["+"]=62;for(k=26;k;){n[sprintf(f="%c",--k+65)]=k;if(k<10) n[sprintf(f,k+48)]=k+52;n[sprintf(f,97+k)]=26+k}}{for(i=1;i<=length;){if((s=\ substr($0,i++,1))in n){c=n[s];if(1==k%=4){b=z*4+(c-(z=c%16))/16}else if(!k)z=c else if(k==2){b=z*16+(c-(z=c%4))/4}else if(k==3)b=z*64+c;if(k++)printf(f,b)}}}