|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
Thanks, I'll keep hunting. The file date is not necessarily the run date.
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > bashing a file date into a variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|