[ale] Bash Prompt Programming Question

Chris Ricker kaboom at gatech.edu
Wed May 21 20:14:27 EDT 2003

On Wed, 21 May 2003, Jonathan Glass wrote:

> Each managed switch has 4 units and 24 ports.  If it returns "Port 25"
> then I know it is on another switch.  How can I check 4 lines of input
> (from stdout) for "Port 25", and if I see it, then I move to the next
> switch, and if I don't, then I know either (a) the machine is not online,
> or (b) it is online and it is on "Unit x port y" where y<25.  Any tips?  I
> can do this when I can control the output to a single line, and use "cut",
> but I'm at a loss as to how to capture multiple lines of input, parse it,
> then output only what I want.  Help!

Assuming I'm following what you're asking, use grep to match rows, then cut
to select columns from the grabbed rows

(though awk or perl would certainly be more elegant)

Ale mailing list
Ale at ale.org

More information about the Ale mailing list