Change time with current year


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Change time with current year
# 1  
Old 07-04-2012
Change time with current year

Hi,

How can i change the time below (red font) with the current year?

Thank You in advance.

hostname 2007-Feb-9 /u100/DEVCO/Patching a.log
hostname 2010-Jun-25 /u100/DEVCO/DumpCleaner a.log
hostname 2011-Jun-25 /u100/DEVCO/DumpCleaner/sample a.log
hostname 23:44-Jun-25 /u100/DEVCO/DumpCleaner/sample b.log
hostname 23:44-Jun-25 /u100/DEVCO/DumpCleaner/Recycle a.log
hostname 23:44-Jun-25 /u100/DEVCO/DumpCleaner/Recycle b.log
# 2  
Old 07-04-2012
Code:
 
$ awk -v d=`date +%Y` '{sub(/[0-9][0-9]:[0-9][0-9]/,d)}1' input.txt
hostname 2007-Feb-9 /u100/DEVCO/Patching a.log
hostname 2010-Jun-25 /u100/DEVCO/DumpCleaner a.log
hostname 2011-Jun-25 /u100/DEVCO/DumpCleaner/sample a.log
hostname 2012-Jun-25 /u100/DEVCO/DumpCleaner/sample b.log
hostname 2012-Jun-25 /u100/DEVCO/DumpCleaner/Recycle a.log
hostname 2012-Jun-25 /u100/DEVCO/DumpCleaner/Recycle b.log

use nawk in solaris

use the code tag, next time

https://www.unix.com/how-post-unix-li...code-tags.html
This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 07-04-2012
Code:
$ sed "s,..:..-,$(date +%Y)-,g" infile
hostname 2007-Feb-9 /u100/DEVCO/Patching a.log
hostname 2010-Jun-25 /u100/DEVCO/DumpCleaner a.log
hostname 2011-Jun-25 /u100/DEVCO/DumpCleaner/sample a.log
hostname 2012-Jun-25 /u100/DEVCO/DumpCleaner/sample b.log
hostname 2012-Jun-25 /u100/DEVCO/DumpCleaner/Recycle a.log
hostname 2012-Jun-25 /u100/DEVCO/DumpCleaner/Recycle b.log
$

This User Gave Thanks to jayan_jay For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert UTC time into current UNIX sever time zone

Hi guys thanks for the help for my previous posts.Now i have a requirement that i download a XMl file which has UTC time stamp.I need to convert UTC time into Unix server timezone. For ex if the time zone of unix server is CDT then i need to convert into CDT.whatever may be the system time... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

2. Shell Programming and Scripting

To get the time exactly 24hrs from the current time

Hi guys, I am having file which contains below data. 2012-04-24 08:40:13 10739022730 1027699274PersonInfoShipTO details missing FirstName,LastName, 2012-04-24 08:40:13 10739022730 1027699274PersonInfoShipTO details missing FirstName,LastName, 2012-04-24 08:40:13 ... (2 Replies)
Discussion started by: mohanalakshmi
2 Replies

3. Shell Programming and Scripting

Displaying current date time of EDT in IST time

Hi Folks, My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST. IST time leads 9:30 mins to EDT. and i wrote something like below. ... (6 Replies)
Discussion started by: Showdown
6 Replies

4. Slackware

/boot: how do I change the current kernel?

Slackware 14.0 Hi: I once changed the smp kernel running in my system by another one in /boot. What I did was to relink /boot/System.map, /boot/vmlinuz and /boot/config. But I don't remember if I did something else. Would that alone be OK. (4 Replies)
Discussion started by: stf92
4 Replies

5. Shell Programming and Scripting

How to pass current year and month in FOR LOOP in UNIX shell scripting?

Hi Team, I have created a script and using FOR LOOP like this and it is working fine. for Month in 201212 201301 201302 201303 do echo "Starting the statistics gathering of $Month partitions " done But in my scripts the " Month " variable is hard-coded. Can you please any one... (3 Replies)
Discussion started by: shoan
3 Replies

6. Post Here to Contact Site Administrators and Moderators

change the year in the event prediction market

Can you change the year in the event prediction market Facebook Stock Will Be Over $70 a Share By the End of 2102? (Closes for placing Bits on 09-30-12 - 10:30 PM) (8 Replies)
Discussion started by: itkamaraj
8 Replies

7. UNIX for Dummies Questions & Answers

comparing field to current year

Hi, I have a comma delimited file that contains name, account number, and account date/time(example record below). I want to pull off all the records that have an account date greater than 8/1 of the current year, and create a new file with those records. So for this year, it would take... (6 Replies)
Discussion started by: keeferb
6 Replies

8. Shell Programming and Scripting

read file and print additional rows till current year

Hi all i have a file like 2006,1,2 2007,2,3 2008,3,4 I will read this and my output should be like 2006,1,2 2007,1,2 2008,1,2 2007,2,3 2008,2,3 2008,3,4 Giving the explanation, we will read the first line of the file and if the year any other than current year, we will print as many... (1 Reply)
Discussion started by: vasuarjula
1 Replies

9. Solaris

change year in the server

HOw do I change the year in Solaris server. I changed the timezone to IST which caused the year to change to 2015. How do I change the year?? (1 Reply)
Discussion started by: krishan
1 Replies

10. IP Networking

change my current IP address

Dear All , I have Sun Solaris 8 machine . during installation i gave the machine ip address 192.168.0.50 and gatway 192.168.0.1 . now i hvae to change the IP address and the gateway ! how ?? i know i have to use ifconfig , but how can i change it and the gateway ??? also where from i... (4 Replies)
Discussion started by: tamemi
4 Replies
Login or Register to Ask a Question