url to local path
with awk to shell
idk if its useful for much tbh

# tc_uri
# $1=$url
# $2=$local_prefix_path
#
# eg tc_uri "$url" "$local_path_prefix"
#
# eg tc_uri http://tinycorelinux.net/13.x/x86/tcz/info.lst.gz /tmp
#
function tc_uri(){
url="${1-'http://tinycorelinux.net/13.x/x86/tcz/provides.db.gz'}";
shift
echo "$url" | busybox awk -v path_prefix="$1" -F"/" '
function get_path(u ,path ){
colafter=5
split(u,path,"/")
path_length=length(path)
p=""
pc=0
for(i in path) {
if( i > colafter && i <= path_length -1 ) {
pc=(pc+1);
if(pc>1){ p=p"/"path[i] }else{ p=path[i] }
}
}
return p ;
}
function mkpathstr(u){
protocall=$1"//"
domain=$2
path=get_path($0)
remotepath=$0
file=$NF
ver=$4
arch=$5
localpath=path_prefix"/"ver"/"arch"/"path"/"file
}
{
mkpathstr($0)
# return vars from awk
print protocall, remotepath , path , file , ver , arch ,localpath
}
' ; }
url="$1"
pathprefix="$2"
# read vars into script
read protocall remotepath path file ver arch localpath < <( tc_uri "${@}" )
echo -e "vars:\nprotocall : $protocall \nremotepath : $remotepath \npath : $path \nfile : $file \nver : $ver \narch : $arch \nlocalpath : $localpath "
# eg ?..
# mkdir -p $(dirname $localpath)
# wget -O$localpath $remotepath