The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AWK help please - beginner COLLEGE UNIX for Dummies Questions & Answers 4 06-13-2007 08:40 AM
Beginner C frustrated1 High Level Programming 2 05-21-2007 03:14 PM
Please help. I am a beginner. Lykathea Aflame Shell Programming and Scripting 1 04-26-2006 02:46 AM
Shell Script for Beginner aaron_fong Shell Programming and Scripting 3 07-18-2005 03:24 AM
Beginner trying to write a shell script! duncan_glover Shell Programming and Scripting 3 08-19-2002 11:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-16-2008
martyb555 martyb555 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 4
Beginner needs help with script

I would like to get a sample script (ksh or bash, or both so I could see the differences)

What I want to do with the script is send an daily email to myself that contains the following:
  • The number of files in a directory
  • The total size of the files in that directory
  • The contents of a file whos name has yesterdays date ( typical filename = dailyLog.20070216 )

I also want to delete files greater that n days old in a directory
  #2 (permalink)  
Old 02-16-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,805
Here is a start.. You need to use find.

Code:
# find files older than 10 days and delete them
find /path/to/directory -type f -mtime +10 -exec rm -f {} \;
# count files
echo "file count \c"
find  /path/to/directory -type f -print | wc -l

See Perderabo's datecalc script in the FAQ on date arithmetic to get yesterday, tomorrow, etc. Then build a filename, use cat to display the file
  #3 (permalink)  
Old 02-16-2008
martyb555 martyb555 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 4
Thanks Jim,

I got the code for datecalc, it requires the following format

The code I am using to get yesterdays date is;

curr_time=`date +"%Y-%m-%d"`
yesterday=`./datecalc.ksh -a $curr_time -1`


Also how would I send all of that stuff in an email?

Last edited by martyb555; 02-16-2008 at 03:59 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On




All times are GMT -4. The time now is 03:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0