Diplay current time stamp in the output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Diplay current time stamp in the output
# 1  
Old 06-20-2018
Diplay current time stamp in the output

I want to display the command output in a particular format. can you please suggest how can i do this
Output of the command
Code:
Name= XYZ
Company= Alpha
Department= Accounts
Country= Singapore

Name=MNC
Company= Beta
Department= Engineering
country=Malta

Name=ABC
Company=Gamma
Department=Medical
Country=sweden
.
.

********************************************
Desired format to display the output
*********************************************

Code:
Current_Time_stamp, Name=XYZ,Company=Aplha,Department=Accounts,Country=Singapore

Current_Time_stamp, Name=MNC,Company=Beta,Department=Engineering,Country=Malta

Current_Time_stamp, Name=ABC,Company=Gamma,Department=Medical,Country=Sweden


Last edited by vgersh99; 06-20-2018 at 11:18 AM.. Reason: code tags, please!
# 2  
Old 06-20-2018
Code:
awk -v d="$(date '+%m/%d/%Y %H:%M:%S')" '$1=d OFS $1' RS= FS='\n' OFS=, myFile

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 06-21-2018
Thanks for your reply.When I am running the script as per your code then i am getting the below output. The timestamp is showing only in one line.. can you please suggest

Code:
Current_Time_stamp,Name=XYZ,Company=Aplha,Department=Accounts,Country=Singapore,Name=MNC,Company=Beta,Department=Engineering,Country=Malta,Name=ABC,Company=Gamma,Department=Medical,Country=Sweden


I want to display the time stamp in separate lines. I need the output in this format :-

Code:
Current_Time_stamp, Name=XYZ,Company=Aplha,Department=Accounts,Country=Singapore

Current_Time_stamp, Name=MNC,Company=Beta,Department=Engineering,Country=Malta

Current_Time_stamp, Name=ABC,Company=Gamma,Department=Medical,Country=Sweden

---------- Post updated at 02:44 PM ---------- Previous update was at 10:27 AM ----------

Please ignore my previous comments.
Your code is working . Thanks a lot Smilie

Last edited by Don Cragun; 06-21-2018 at 04:54 AM.. Reason: Add CODE tags, again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add current time stamp column in existing csv file

Hi , I want to add a new column 'current_time stamp' in my existing csv file with current time stamp for all the records.I tried something this but this is printing 0 with date & time and printed date one line above header.Please help awk -F "," 'BEGIN{ OFS="," } {$6=system("date... (5 Replies)
Discussion started by: netdbaind
5 Replies

2. 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

3. Shell Programming and Scripting

How do i find a file with the current time stamp in it??

I want to find a file using find or any utility having the current date time stamp..... I have an alternate way to do that.... but that is too way out of logic... so looking out something with find itself (5 Replies)
Discussion started by: nikhil jain
5 Replies

4. Solaris

Find command output gives one day before time stamp

Hi All, I am listing the files which are 4 hours older. For this first I have creted a dummy file with the 4 hours before timestamp, then I am using the below find command, find /path/ -type f ! -newer 4_hours_oledr_file -exec ls -lrt {} \; I am getting the files which are older than... (13 Replies)
Discussion started by: velava
13 Replies

5. Solaris

System time and Cron time stamp not matching

On Solaris 10 server the system date won't match with the timestamp on files created by a cron jobs, Please help here is what i get when i check for system date infodba-ie10ux014:/tcpdv1_ie10/tcadmin/bin\n\r-> date Tue Apr 24 15:27:43 GMT 2012at same time i executed a cron job, and checked... (4 Replies)
Discussion started by: karghum
4 Replies

6. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

7. Shell Programming and Scripting

How to Unzip to current time stamp?

I need the current time stamp to the unzipped file , any helpful option in unzip command ? Thank you. (1 Reply)
Discussion started by: almanto
1 Replies

8. Shell Programming and Scripting

unziping to current time stamp

Basically when ever unzipping the .zip file , what ever the file exist in the .zip file with the time stamp, that is the same time stamp after unzip. But if i need the current time stamp to the unzipped file(time stamp whenever unzip process occurs ) any helpful option in unzip command ??? ... (4 Replies)
Discussion started by: posix
4 Replies

9. Shell Programming and Scripting

Prefix the current date and time to the output of ps

Hi, I need to write a script, that will take the current date, time, and the output from # ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm and spit it to a file, so it'll look like this... PID TID CLS RTPRIO NI PRI PSR %CPU STAT WCHAN COMMAND 1 1 TS... (2 Replies)
Discussion started by: Bloke
2 Replies

10. Shell Programming and Scripting

Need help for AWK output with current time

Hi, Any suggestion to get the AWK output with time in each line ? I want to have the vmstat in solaris with time append to everyline like this: kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr s0 s1 s3 sd in sy cs... (2 Replies)
Discussion started by: roxy2k
2 Replies
Login or Register to Ask a Question