Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script.sh need to organize output data

Status
Not open for further replies.

dreamaz

Technical User
Dec 18, 2002
184
CA
Hello,

I have a script that outputs data i need for reporting:

#!/bin/csh
date >> /var/tmp/nat_table_output.out
/opt/CPfw1-R55p/bin/fw tab -t fwx_alloc -s >> /var/tmp/nat_table_output.out

As per above i get the following output:

Fri Jul 6 22:00:00 EDT 2007
HOST NAME ID #VALS #PEAK #SLINKS
localhost fwx_alloc 8187 17666 30421 0

The first row is date ofcourse, row 2 and 3 are automatically formatted that way by the fw tab command i run for my firewall. Im trying to get the date/time stamp as part of the localhost entry instead of its own row at the top of each entry.. Not sure how this can be done, i have very new to this, but i'd like my outputed data to look like:


DATE HOST NAME ID #VALS #PEAK #SLINKS
Fri Jul 6 21:30:00 EDT 2007 localhost fwx_alloc 8187 17124 30421 0

DATE HOST NAME ID #VALS #PEAK #SLINKS
Fri Jul 6 21:45:01 EDT 2007 localhost fwx_alloc 8187 18880 30421 0

DATE HOST NAME ID #VALS #PEAK #SLINKS
Fri Jul 6 22:00:00 EDT 2007 localhost fwx_alloc 8187 17666 30421 0

SO basically, need to add the DATE title and column, and the date/time stamp under it appended to the table

Hope this makes sense, any help is appreciated.

Thanks,

dR
 
Sorry, not a csh'er, but this should work for zsh, bash, sh, ksh:

Code:
/opt/CPfw1-R55p/bin/fw tab -t fwx_alloc -s \|
  sed 's/HOST/DATE                         HOST/' \|
  sed "s/localhost/`date` localhost/" \
  >> /var/tmp/nat_table_output.out

--jeff
(just joined today, hope sig is ok)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top