[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: quick scripting question - finding occurrence in many lines



The simplest case:
awk '{for (i=1;i<=NF;i++) {if ($i~/Processor/) print $(i-1)} }' file



"michael писал(а):
"
> I've been trying to do this with 'awk' but am hitting probs (not used
> awk for ages!) so all offers welcome!
>
> Given a multiple line file, IN, that contains the word Processor
> (possibly split over 2 lines) I wish to output the field immediately
> preceeding Processor.
>
> eg for
>
> junk info 18 Pro
> cessor
>
> I wish to get the field '18'
>
> Cheers, Michael
>
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: