The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Get date from cal function ukatru UNIX for Advanced & Expert Users 3 09-04-2008 05:54 AM
Friendz.. plz help me on this date function. psn123 UNIX for Advanced & Expert Users 14 07-23-2008 04:09 PM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 09:12 AM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 07:44 AM
date function abey Shell Programming and Scripting 2 02-27-2006 05:28 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-11-2008
c00kie88 c00kie88 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 63
Date function

I read man page for etc/shadow field..

on the 8th field, i assume that's the field to change account expire date.

my question is:

What value does the 8th field keep? i assume it's 13514 instead of "Date" value such as 11/10/08.

on the man page, it said: " expire value = 13514 = jan 1, 2007"

How do you get 13514 ?

Is there any calculation involves?
  #2 (permalink)  
Old 10-11-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
It did not say that. If it did it is wrong.

That field is the number of days AFTER Jan 1, 1970 that the account expires - becomes unusable.
  #3 (permalink)  
Old 10-11-2008
c00kie88 c00kie88 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 63
ok..

but how do i convert the date format (10/10/08) to unix format to be used at 8th field?
  #4 (permalink)  
Old 10-11-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
Read the faq article on date arithmetic. It has a link to my datecalc script.

$ ./datecalc -a 2007 1 1 - 1970 1 1
13514
$
  #5 (permalink)  
Old 10-11-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,368
You should read man date for your *NIX, this solution should work on Linux date (GNU coreutils) 5.97
Code:
dt=1/1/07                   # For January 1, 2007
# dt=$(date "+%d/%m%y")     # For current date
var=$(($(date -d $dt "+%s") / 86400))
echo $var
13514
  #6 (permalink)  
Old 10-11-2008
c00kie88 c00kie88 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 63
i made some syntax modification which are:

#old=1/1/07
old=`date +%d%m%y`
var="(`(date -u $old "+%s")`/ 86400)"
echo $var

but i have a problme with the third line..

when i read man page for date, it only supports

usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]

i'm guessing i should use -u but i think it's wrong

Last edited by c00kie88; 10-11-2008 at 07:53 AM..
  #7 (permalink)  
Old 10-11-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,368
What OS? and where you perform the calculation?
Sponsored Links
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 01:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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