HowTo - Handle Massive Standard Output

Introduction - Situation

Many of us have run into situations where a single command spits out hundreds or thousands of lines of ouput.

We're only interested in one or few lines and we're interested in a few hundred servers. How do we go about obtaining such little information out of a mass output from hundreds of servers, only in matters of a minute?


Build into our brain the capability to master the following commands. They are NOT hard to master. All you have to do is read through this series of tips and you will be able to command the entire  data center (regardless of how many servers) with ease.


Each of those commands have multiple switches that can be used to control the way output show up.

In this series of tips, I will break things into couple parts, each part covering one command and its most powerful/useful switches that can help you to not only find the exact data that you're mining for, but also to put things into a very very human readable format.

I'd like to ask all readers of this introduction to do couple things in advance:

1. Read my tutorial and setup passwordless SSH in your environment.

2. Run this non-intrusive command on your Linux server:

Review the output of this command, get a quick understanding of how things show up there;

There are sections such as "System Information" where the Manufacturer, UUID, Serial Number of the motherboard are listed.

There are other sections where the same headers (Manufacturer, Serial Number, etc) are listed.

Imagine this: If you wanted to search for the Manufacturer of the motherboard, you will get probably dozens of lines pertaining to each hardware component in the report.

Imagine this too: You want to show only the "System Information" block of the report, and you're only interested in the Manufacturer, Product Name, Family, Serial lines. Discard the rest, then format the output into a column report like this

Server Name    Manufacturer      Product Description   Serial Number
===========    ===============   ===================   =============
wxv5238        Hewlett-Packard   ProLiant DL385G7      243897234987
erw3489        IBM               xSeries 3850          239472384798
dfw2342        Dell              PowerEdge 5900        234987234879

By running a single line command from your linux laptop, can you show this output?

Part 1: The grep Command
Part 2: The awk Command 
Part 3: The sed Command
Part 4: Miscellaneous Commands

No comments:

Post a Comment

Help a friend, share your knowledge