Forum Discussion

keithhubb's avatar
keithhubb
Icon for Employee rankEmployee
Oct 28, 2015

Combine and Modify Grep Output

Hi, I'm trying to write a script to output virtual server stats. Can anyone help me modify the output?

Right now the GREP output looks like this:

Ltm::Virtual Server: www.website.com.443
  Bits In                                 2.1G          0        -
  Bits Out                                2.3G          0        -
Ltm::Virtual Server: www.website.com.80
  Bits In                                 1.4G          0        -
  Bits Out                              740.8M          0        -

I need help making the output like this:

www.website.com.443 Bits In 2.1G Bits Out 2.3G
www.website.com.80 Bits In 1.4G Bits Out 740.8M

Afterwards, I can diff files from different dates, and figure out which VIPS are not being used.

  • Here's something quick if your grep output is in output.txt:

    root@dev-localhost:~ sed 'N;N;s/\n//g' output.txt | awk '{print $3, $4, $5, $6, $9, $10, $11}'
    www.website.com.443 Bits In 2.1G Bits Out 2.3G
    www.website.com.80 Bits In 1.4G Bits Out 740.8M