nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Shell Script To Check Null Files ( size greater than zero )

This is a discussion on Shell Script To Check Null Files ( size greater than zero ) within the Shell scripting forums, part of the Development/Scripting category; Hello, I have a script to find orphaned files and directories. After running it saves it ouput under /tmp. I ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 21-05-2009, 02:29 AM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
shellscript916 is on a distinguished road
Default Shell Script To Check Null Files ( size greater than zero )

Hello,

I have a script to find orphaned files and directories. After running it saves it ouput under /tmp. I want to add a functionality to it so that it print in that file that no orphan files were found if the script did not find anything. I am pasting the script for clarity.
Can someone help me in adding that functionality.

Code:
#!/usr/bin/sh
OSTYPE=`uname -s`
TEMP=/tmp/orphan
 
case $OSTYPE in
HP-UX)
find / -xdev \( -type f -o -type d \) \( -nouser -o -nogroup \) > ${TEMP} 2>&1;;
AIX)
find / ! -fstype nfs \( -type f -o -type d \) \( -nouser -o -nogroup \) > ${TEMP} 2>&1;;
*)
find / -local \( -type f -o -type d \) \( -nouser -o -nogroup \) > ${TEMP} 2>&1;;
esac
 
exit 0

Last edited by nixcraft; 22-05-2009 at 02:21 AM.
Reply With Quote
  #2 (permalink)  
Old 22-05-2009, 12:37 AM
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 78
Thanks: 0
Thanked 14 Times in 14 Posts
Rep Power: 2
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default


When you post code, please wrap it in [code] tags.

Code:
[ -s "$temp" ] && echo found || echo not found
Reply With Quote
Reply

Tags
linux , shell scripting , test , test file size , unix


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Backup Shell Script That Searches for all the files greater then 200 bytes nextcmchiranjeevi Shell scripting 2 11-02-2009 11:44 PM
Shell script to check the disk space on remote systems vijayscripts Shell scripting 5 21-10-2007 06:29 PM
Shell script for automatic conversion of files in tar files kasimani Shell scripting 2 08-02-2007 03:45 PM
shell script to open log files and check for faults trueman82 Shell scripting 1 23-11-2006 02:35 AM
Linux command to check size of hard drive disk gbdood Linux software 2 27-08-2006 09:44 AM


All times are GMT +5.5. The time now is 03:06 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38