Write a script to delete zero sized files from a given directory (and all its sub-directories).

clear

while true;do

echo -e “Enter the directory name for deleting the zero size file::\c”

read path1

[[ -d $path1 ]] && break

echo Invalid name

done

zero=find $path1 -empty

for i in $zero

do

if [ -f “$i” ]

then

rm “$i”

echo Zero file are deleted in $path1 directory

fi

done

 

OUTPUT::

 

Enter the directory name for deleting the zero size file::a2

Zero file are deleted in a2 directory

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.