UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 12th, 2005, 08:55 PM
sarahk sarahk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Auckland, New Zealand
Posts: 6 sarahk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 32 sec
Reputation Power: 0
bashing a file date into a variable

I've written a bash script to read the contents of a file and email it to me. I'd like to change the subject so that it includes the file modification date.

It looks like I should be using stat to do that, and while man stat works stat doesn't seem to actually be there

Code:
> stat core
ksh: stat:  not found


Is this me falling into the depths of newbie-hell and missing something obvious or does stat not exist?

Sarah

Reply With Quote
  #2  
Old July 13th, 2005, 04:19 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,098 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 7 h 51 m 27 sec
Reputation Power: 9
hello sarah
stat is a c-lib function, you cannot use it on cmd line
sure you can write an onw 'stat'cmd, for this you need
C knowledge, or use the 'test' cmd, read man pages.
mybe you are seeking for 'file' to get the type of file,
i dont know yous OS
i also dont understand what you are trying to do
__________________
working on Solaris[5-9], preferred languages french and C.

Reply With Quote
  #3  
Old July 13th, 2005, 04:33 PM
sarahk sarahk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Auckland, New Zealand
Posts: 6 sarahk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 32 sec
Reputation Power: 0
I'm using bash to analyse a file with the output going to a log file. I'm them emailing that log file to myself. Because I might do that every day I want the emails to have the time in the subject so that I can find the one I want more easily. I know the email has a timestamp too but I'm just wanting to have the date in the subject.

The box is an old Unix server.

If this was PHP it'd be done in a flash, but bash scipting doesn't seem to have that type of functionality.

thanks

Sarah

Reply With Quote
  #4  
Old July 14th, 2005, 12:55 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
The "stat" tool doesn't seem to be installed on your server. In Linux, it's part of the "coreutils" package.

You can get the current date+time with this, if this helps:
Code:
CURDATE=`date +%Y-%m-%d-%H-%M`

Or you can use "ls -l filename" to get the modification time of a file too.

guggach:
My FreeBSD, NetBSD and Linux installations all come with a command line tool stat(1)... but surprisingly (at least to me), Darwin doesn't have one either

M.
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #5  
Old July 14th, 2005, 04:21 AM
sarahk sarahk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Auckland, New Zealand
Posts: 6 sarahk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 32 sec
Reputation Power: 0
Talking

Thanks, I'll keep hunting. The file date is not necessarily the run date.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > bashing a file date into a variable


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT