Solved

changing year only

Posted on 1997-12-18
3
204 Views
Last Modified: 2010-04-21
does anyone know how to change the year only, without entering in other information such as month, hour, miniute, etc.  Or can i obtain a perl script which will automate this.  I have read the man pages and help files for
'date' but it will not let you enter one field at a time.  You must enter all required fields even if you only want to change only 1 field such as year.  I want to be able to leave the curent time as is, and only modify the year.  Can this be done, and if so, how?
0
Comment
Question by:tcblue
  • 2
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2008420
#!/usr/bin/perl -w
($s,$M,$H,$d,$m,$y) = localtime;
$m += 1;
$y += 1900;
$yy = shift || $y;
system(sprintf("date %02d%02d%02d%02d$yy.%02d",$m,$d,$H,$M,$s));

0
 

Expert Comment

by:grantk
ID: 2008421
Make a shellscript called "xdate", or something:
date `date "+%m%d%H%M$@ .%S"`

Call it with "xdate 98".
0
 

Accepted Solution

by:
grantk earned 50 total points
ID: 2008422
Make a shellscript called "xdate", or something:
date `date "+%m%d%H%M$@ .%S"`

Call it with "xdate 98".
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now