Shell Programming and Scripting

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Diplay current time stamp in the output


👤 Login to reply

    #1  
Old 4 Weeks Ago
swets swets is offline
Registered User
 
Join Date: Jun 2018
Last Activity: 26 June 2018, 1:46 AM EDT
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
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; 4 Weeks Ago at 10:18 AM.. Reason: code tags, please!
Sponsored Links
    #2  
Old 4 Weeks Ago
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is online now Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 21 July 2018, 7:14 PM EDT
Location: Foxborough, MA
Posts: 8,314
Thanks: 260
Thanked 842 Times in 786 Posts
Code:
awk -v d="$(date '+%m/%d/%Y %H:%M:%S')" '$1=d OFS $1' RS= FS='\n' OFS=, myFile

The Following User Says Thank You to vgersh99 For This Useful Post:
swets (4 Weeks Ago)
Sponsored Links
    #3  
Old 4 Weeks Ago
swets swets is offline
Registered User
 
Join Date: Jun 2018
Last Activity: 26 June 2018, 1:46 AM EDT
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
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

Last edited by Don Cragun; 4 Weeks Ago at 03:54 AM.. Reason: Add CODE tags, again.
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Add current time stamp column in existing csv file netdbaind Shell Programming and Scripting 5 01-09-2018 12:09 PM
How do i find a file with the current time stamp in it?? nikhil jain Shell Programming and Scripting 5 04-05-2013 07:03 AM
Find command output gives one day before time stamp velava Solaris 13 10-05-2012 11:10 AM
How to Unzip to current time stamp? almanto Shell Programming and Scripting 1 10-31-2010 05:12 PM
unziping to current time stamp posix Shell Programming and Scripting 4 06-14-2010 01:37 AM



All times are GMT -4. The time now is 07:23 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?