On 3/30/07, James Hatridge <[EMAIL PROTECTED]> wrote:
Hi all,
I have files with mailing addresses in them. There are normally 4-5 lines with
the first line starting with "address: " then the person's name and 3 or 4
more lines of address. Can (how) I use grep to pull all the address out? If
not grep what else?
I don't think grep can handle variable multiline results.
I would attack it with awk. (or gawk).
It is a pretty flexible reporting package.
Ignoring syntax a control file like:
START {print_lines=0; echo "File Header" > "output_file" }
/address:/ {print_lines=4}
{print_lines = print_lines-1
if (print_lines > 0) print $0 >> "output_file"
}
should be the basic code.
Then invoke it with:
awk -f control_file *
FYI: Double check all the above, but it should be enough to point you
in the right direction.
Greg
--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]