Estimate the folder size without unzipping zip file

By mallik034vismobang14 Mar 20202 min read

Estimate
the folder size without unzipping zip file

Many
times, we may face disk or mount point running out of the storage during
unzipping the tar or zip file. We need to estimate the space required for
unzipping the file.

Below the is the sample shell script
which will estimates the space requirement for the unzipping the zip files or
patches.

Notes: 
This is the best practice for
the all kind of patching activities, OH patching, APPS patching. DBAs has to
make sure adequate space is available before the patching activity.

Shell script: 
folder_size_estimation.sh 


#!/bin/ksh
#===============================================================================================#
# Name          : folder_size_estimation.sh                                                     #
# Written by    : Mallik                                                                        #
# Purpose       : This script will Estimate the folder size without unzipping zip file          #
# Pending       : NONE                                                                          #
# Creation Date : 14-MAR-2019                                                                   #
# Version       : 1                                                                             #
# ==============================================================================================#
TODAY_DATE=`date +%d%m%Y_%H%M%S`
find /home/mramadur/patches -name “p*.zip” -print > /home/mramadur/patches/zipfiles.lst
totalsize=0
div=1073741824
for zipfiles in `cat /home/mramadur/patches/zipfiles.lst`
do
size=`unzip -l $zipfiles | tail -1 | awk'{ print $1 }’`
totalsize=`expr “$size” + “$totalsize”`
done
TS=$(echo “scale=2; $totalsize/$div” |bc)
echo $TS GB is needed to unzip the patches



Regards,
Mallik

M
Mallikarjun Ramadurg

Oracle ACE Pro • Oracle SME & Founder of Vismo Technologies. Sharing practical Oracle DBA, RAC and Exadata knowledge.

Get the weekly Vismo digestNew Oracle articles and Q&A in your inbox. No spam.

One email a week. Unsubscribe any time.