Computing.Net > Forums > Unix > awk concatenation date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

awk concatenation date

Reply to Message Icon

Name: xoir
Date: March 30, 2004 at 17:45:22 Pacific
OS: soalris 8
CPU/Ram: ultra 10
Comment:

Hi,
I'm polling by snmp a router but the data polled need a date concatenated for each value,
I'm doing this:

snmpwalk -v 1 -c any 10.1.1.1 OID | awk 'BEGIN {OFS=","} {print $1,$2";"}'

and result is:

74,289;
this means
(IF-id,Value)

and I need attach the date to the values like this:

74,289,19:35:49;
(IF-id,Value,Date)

There is any way I could do this?

regards,
Xoir



Sponsored Link
Ads by Google

Response Number 1
Name: aigles
Date: March 31, 2004 at 07:36:38 Pacific
Reply:

If you want to add the same time (time of execution) for every line :

snmpwalk -v 1 -c any 10.1.1.1 OID | \
awk -v OFS="," -v TIME="`date +'%H:%M:%S'`" \
'{print $1,$2,TIME ";"}'

If you want to add the real time (time when the line is proceeded) for every line, you can do something like this :

snmpwalk -v 1 -c any 10.1.1.1 OID | \
awk -v OFS="," -v TIME="date +'%H:%M:%S'" \
'function Time( t) {
TIME | getline t
close(TIME)
return Time
}
{ print $1,$2,Time() ";" }'


Jean-Pierre.


0

Response Number 2
Name: xoir
Date: March 31, 2004 at 09:15:18 Pacific
Reply:

Yep, the first options should be what I need, but the other is a cool stuff exercise

thanks Jean!

Xoir


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Unix script help SCO compiling problem Ple...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: awk concatenation date

Date/Time compare www.computing.net/answers/unix/datetime-compare/7341.html

Awk getting the quotes right with variable. www.computing.net/answers/unix/awk-getting-the-quotes-right-with-variable/8366.html

date with awk pls help urgent www.computing.net/answers/unix/date-with-awk-pls-help-urgent/5047.html