Re: [opensuse] grep question
- From: "Greg Freemyer" <greg.freemyer@xxxxxxxxx>
- Date: Fri, 30 Mar 2007 12:39:34 -0400
On 3/30/07, James Hatridge <James.Hatridge@xxxxxx> wrote:
Hi all,I don't think grep can handle variable multiline results.
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 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: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
- References:
- [opensuse] grep question
- From: James Hatridge
- [opensuse] grep question
- Prev by Date: [opensuse] grep question
- Next by Date: Re: [opensuse] grep question
- Previous by thread: [opensuse] grep question
- Next by thread: Re: [opensuse] grep question
- Index(es):
Relevant Pages
|