- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: shell script!!
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 02:45 PM
12-26-2004 02:45 PM
i want to write a shell script thats should check size of the given file name. if the file contains zero bytes, remove that file. so any one plz help me. thanks in advance.
ajay.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 04:07 PM
12-26-2004 04:07 PM
Re: shell script!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 05:47 PM
12-26-2004 05:47 PM
Re: shell script!!
it helped me.thanks for your reply.but i want to use 'if' condition or 'test' command to check the file size and then it should remove the empty files. thanks and regards.
ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 06:37 PM
12-26-2004 06:37 PM
Re: shell script!!
find ./ -size 0 -exec rm -i {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2004 02:06 AM
12-27-2004 02:06 AM
Re: shell script!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2004 03:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2005 03:08 AM
01-01-2005 03:08 AM
Re: shell script!!
Conditional expressions are used by the [[ compound command and the test and [ builtin commands to test file attributes and perform string and arithmetic comparisons.
-s file ==> True if file exists and has a size greater than zero.
Regards,
Ross
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 03:32 PM
01-02-2005 03:32 PM
Re: shell script!!
thanks to all who given me suggestions.
regards,
ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2005 10:47 AM
01-03-2005 10:47 AM
Re: shell script!!
If using bash, certainly [[/]] with '-s' is the fastest solution, but if you want multi-platform, it's not the best.
The 'test' ([) application has the '-s' option as well, and it is fully multiplatform:
if [ -s /file/name.here ]
then
rm -f /file/name.here
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2005 02:33 PM
01-09-2005 02:33 PM
Re: shell script!!
i tryed your script but it dint work browne .y i dont know.it cant delete the empty file. anyway thanks.
ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2005 03:44 PM
01-09-2005 03:44 PM
Re: shell script!!
Ajay,
Try this code below. I think Stewart missed one "!".
==============================
#!/bin/bash
if [ ! -s emptyfile ]
then
echo "deleting emptyfile"
rm -f emptyfile
fi
===============================
Again from the bash man page (man bash):
Conditional expressions are used by the [[ compound command and the test and [ builtin commands to test file attributes and perform string and arithmetic comparisons.
-s file ==> True if file exists and has a size greater than zero.
HTH,
Ross
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2005 04:51 PM
01-09-2005 04:51 PM
Re: shell script!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2005 12:28 PM
01-13-2005 12:28 PM
Re: shell script!!
thanks for your support. your suggestions helped me.slowly i am learning shell scripting.your suggestions helped me to think in different way.
thanks once again
regards,
ajay