Solved

changing year only

Posted on 1997-12-18
3
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.
Suggested Courses

630 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