Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

changing year only

Posted on 1997-12-18
3
Medium Priority
?
211 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 100 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:
Suggested Courses

661 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