# find space of some file
find . -type f -name "*.pdf" \
  | xargs -I%r% du -s "%r%" 2>/dev/null \
  | awk 'BEGIN{ s=0 } $1~/^[0-9]+/ {s=s+$1} END{print s}'
BEGIN{
  print "start script..."
}

function _exec(cmd, file) {
  e=cmd" '"file"'";
  print(e);
  system(e);
}

$1~/\.(ZIP|zip)$/{
  cmd="unzip";
  _exec(cmd, $1);
}

$1~/\.(rar|RAR)$/{
  cmd="unrar x";
  _exec(cmd, $1);
}

$1~/\.(7z|7Z)$/{
  cmd="7zr x";
  _exec(cmd, $1);
}

$1~/(tar|TAR)\.(gz|GZ)$/{
  cmd="tar zxvf";
  _exec(cmd, $1);
}

END{
  print "script ended"
}