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
- Re: [opensuse] grep question
... On Friday 30 March 2007 06:47, James Hatridge wrote: ... I have files with mailing
addresses in them. ... Can I use grep to pull ... Randall Schulz ...
(SuSE) - Re: [opensuse] grep question
... On Friday 30 March 2007 15:47, James Hatridge wrote: ... I have files with mailing
addresses in them. ... Can I use grep to pull all the address ... For additional
commands, e-mail: opensuse+help@xxxxxxxxxxxx ... (SuSE) - Re: General UNIX puzzle
... All of those (sed, awk, grep) involve making a copy of the original file ...
The gnu shtool is one of the most useful tools for this for in-place ... A Galileo could
no more be elected president of the United States than ... (freebsd-questions) - Re: ssh and chroot
... ++ echo /bin/mkdir ... ++ awk '' ... ++ grep '^/' ...
(comp.security.ssh) - Re: The smartest band in the world?
... I mainly use grep, but I'm ... going to learn awk and sed and improve
my bash scripting. ... Oracle accreditation coure, well in the grad courses at least,
everything ... (alt.guitar)