Delete the file which crossed 2GB | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Delete the file which crossed 2GB

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-19-2013
Rahulne25 Rahulne25 is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 18 February 2014, 6:09 AM EST
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Linux Delete the file which crossed 2GB

Hi ,
I wants to create the bash script for deleting the specified 2gb file and wants to take the backup before doing that.

please help me how to do the same,I use RHEL5 server
Sponsored Links
    #2  
Old 09-19-2013
alister alister is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 11 June 2014, 8:40 PM EDT
Posts: 3,231
Thanks: 179
Thanked 973 Times in 789 Posts
What have you tried?

Regards,
Alister
Sponsored Links
    #3  
Old 09-19-2013
Rahulne25 Rahulne25 is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 18 February 2014, 6:09 AM EST
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,
I have tried below script but it is deleting file which is not 0 size..

it is not deleting whichis morethen 2gb file

Code:
echo "Enter any file name: "
read a
if [ -s $a ] 
then
echo $a" File has size > 2GB"else
rm $a
echo $a" File is Deleted which has size = 2GB"
else
echo "File not exist"
fi

Moderator's Comments:
Please use code tags next time! look at the PMs you already received for how to

Last edited by vbe; 09-19-2013 at 01:59 PM.. Reason: code tags !!!
    #4  
Old 09-19-2013
RavinderSingh13 RavinderSingh13 is offline
Registered User
 
Join Date: May 2013
Last Activity: 21 November 2014, 10:08 AM EST
Location: Chennai
Posts: 800
Thanks: 222
Thanked 193 Times in 186 Posts
Hi,

the command
Code:
 -s

gives true value if a file size is Non- Zero.
So you can try to do compare by size in code.



Thanks,
R. Singh
Sponsored Links
    #5  
Old 09-19-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 21 November 2014, 1:05 PM EST
Location: Aachen, Germany
Posts: 4,671
Thanks: 78
Thanked 1,154 Times in 1,084 Posts
Is the stat command available on your system?

Code:
if [ "$(stat -c%s $a)" -gt 2147483648 ]
then backup $a                     # whatever backup system you want to use
     check backup success
     rm $a
else ...


Last edited by RudiC; 09-19-2013 at 02:35 PM..
Sponsored Links
    #6  
Old 09-20-2013
Rahulne25 Rahulne25 is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 18 February 2014, 6:09 AM EST
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Linux

Thanks, its working fine in RHEL,but i am getting an error in solaris10 server when i execute that script....
Sponsored Links
    #7  
Old 09-20-2013
alister alister is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 11 June 2014, 8:40 PM EDT
Posts: 3,231
Thanks: 179
Thanked 973 Times in 789 Posts
Quote:
Originally Posted by Rahulne25 View Post
Thanks, its working fine in RHEL,but i am getting an error in solaris10 server when i execute that script....
Simply saying "an error" is absolutely useless feedback. At the very least, copy/paste any error messages. If there are none, then describe the error in detail.

I suspect the error is caused by not having stat or having a stat implementation that implements a different command line option syntax.

Regards,
Alister
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to create a file more than 2GB risshanth UNIX for Advanced & Expert Users 1 07-12-2010 06:25 PM
unzipping file > 2gb manoj.solaris Linux 5 08-14-2009 04:02 PM
Creating > 2GB file markper AIX 4 07-24-2008 07:45 AM
How to find filesystems crossed 90% capacity shaan_dmp UNIX for Dummies Questions & Answers 4 11-13-2007 01:22 AM
File size exceeding 2GB Nadeem Mistry UNIX for Dummies Questions & Answers 3 07-30-2001 07:53 AM



All times are GMT -4. The time now is 12:50 AM.