Solved

changing year only

Posted on 1997-12-18
3
203 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

705 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

21 Experts available now in Live!

Get 1:1 Help Now