The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 11-25-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,296
You should be able to pipe your output just into that sed command.
infile is just the filename I saved your example on my harddisk and I feed sed not with a pipe in front of it but just with this infile.

If the output you want to parse varies a lot, you can't go like that. You have to know how your output looks as close as possible.


Code:
sed -n              # Print only the stuff we want to see; else it prints all 
                    # the stuff it is processing additionally
'                   # Here starts the regex and commands
/^$/,/^$/           # The / starts and ends a pattern; ^ is the start of a
                    # line, $ the end of a line and since nothing is specified 
                    # between it, it must be an empty line. So writing two 
                    # patterns separated with a comma is like giving a 
                    # range "from" "to"
{/^[^ ]/p}          # When the range is separated, do the command in curled
                    # braces. The command inside the braces says to get a
                    # pattern, that does not start with a blank. Inside square brackets the ^ means "not". The p simply stands for print.


' infile