Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Shell Script to delete the zero sized file using if and for

Posted By: Bin Fischer     Category: Unix / Linux / Ubuntu     Views: 9135

Write a Shell Script to delete the zero sized file using if and for.

Code for Shell Script to delete the zero sized file using if and for in Unix / Linux / Ubuntu

clear
echo "Enter any file name: "
read filenm
if [ -e $filenm ]
then
    echo $filenm" File exist"if [ -s $filenm ]
    then
        echo $filenm" File has size > 0"else
        rm $filenm
        echo $filenm" File is Deleted which has size = 0"
    fi
else
    echo "File not exist"
fi




OUTPUT
***********
[04mca58@LINTEL 04mca58]$ sh size.sh

Enter any file name:
del.sh
del.sh File exist
del.sh File is Deleted which has size = 0
  
Share: 



Bin Fischer
Bin Fischer author of Shell Script to delete the zero sized file using if and for is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 

Other Interesting Articles in Unix / Linux / Ubuntu:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!