swets
June 20, 2018, 10:11am
1
I want to display the command output in a particular format. can you please suggest how can i do this
Output of the command
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
*********************************************
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
awk -v d="$(date '+%m/%d/%Y %H:%M:%S')" '$1=d OFS $1' RS= FS='\n' OFS=, myFile
1 Like
swets
June 21, 2018, 1:44am
3
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
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 :-
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