Appending standard C Time on each line out output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Appending standard C Time on each line out output
# 1  
Old 11-24-2011
Question Appending standard C Time on each line out output

I have a command :
Code:
nawk 'BEGIN{print srand()}'

which gives the amount of seconds between January 1st 1970 00:00:00 (Unix Epoch) and the present time, to the closest second and I would want to append this time stamp every minute in a file which contains the data below which also has one row added every minute.

Current file output
1955 891
2270 1930
2173 1937

Required output:
1322123179 1955 891
1322123663 2270 1930

where the first column is the Unix Epoch time appended for the particular time the line of data was generated.
# 2  
Old 11-24-2011
The file that gets appended, let's call it logfile, the new file: newlogfile
Code:
tail -f logfile | nawk '{ print srand(), $0}'  > newlogfile

You don't want the BEGIN{} function.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

2. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

3. Shell Programming and Scripting

Help: transform unix time format to standard

Hello All, Do you have any idea, how can I transform the unix time format to standard: time_last_login=1268057983 :confused: I would like to use the transformation in a AIX shell script :( (6 Replies)
Discussion started by: kalaso
6 Replies

4. Shell Programming and Scripting

sed command works from cmd line to standard output but will not write to file

Hi all .... vexing problem here ... I am using sed to replace some special characters in a .txt file: sed -e 's/_<ED>_/_355_/g;s/_<F3>_/_363_/g;s/_<E1>_/_341_/g' filename.txt This command replaces <ED> with í , <F3> with ó and <E1> with á. When I run the command to standard output, it works... (1 Reply)
Discussion started by: crumplecrap
1 Replies

5. UNIX for Dummies Questions & Answers

Redirect Standard output and standard error into spreadsheet

Hey, I'm completely new at this and I was wondering if there is a way that I would be able to redirect the log files in a directories standard output and standard error into and excel spreadsheet in anyway? Please remember don't use too advanced of terminology as I just started using shell... (6 Replies)
Discussion started by: killaram
6 Replies

6. Shell Programming and Scripting

How do you convert scientific time to standard

Hi All, I'm new to this forum, and appreciate any assistance with my issue. I have a shell script that logs into an oracle DB and runs a sqlplus query. Everything works great except for the time I get. I'm new to shell so bare with me. What would be the code and where do I place it? My... (18 Replies)
Discussion started by: cg_dude
18 Replies

7. Shell Programming and Scripting

Convert Unix Time to Standard Time

I have a list of interfaces and time the interface was last active. I can't figure out how to convert the time in the second column, Fa1/14 0 Se0/0/0 0 Fa1/11 0 Fa1/9 0 Fa1/0 0 Se0/0/1 1240401408 Gi1/0 0 Fa0/0 1240401408 Fa1/3 0 Fa1/8 0 Fa1/15 0 Fa1/13 0 Fa1/10 0 Fa1/1 0 Fa1/12... (7 Replies)
Discussion started by: mrlayance
7 Replies

8. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

9. Shell Programming and Scripting

capturing line from script output and appending to a file

Hi all, I did some searching in this forum but can't find anything that matches the issue I'm bumping heads with. On a CentOS4/Postfix (and bash everywhere) mail gateway box I run a command periodically to purge the Postfix queue of messages "From:MAILER-DAEMON". This is the one line'r... (6 Replies)
Discussion started by: wally_welder
6 Replies

10. Shell Programming and Scripting

Convert milliseconds to standard time

hello, I have the uptime of the server showing as upTime=2427742050 How do I convert it to standard time. Thanks Chiru (1 Reply)
Discussion started by: chiru_h
1 Replies
Login or Register to Ask a Question