Print word 1 in line 1 and word 2 in line 2 if it matches a pattern

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print word 1 in line 1 and word 2 in line 2 if it matches a pattern
# 8  
Old 08-31-2009
nawk 'BEGIN{flag=0}{if($1=="MATCH1"){flag=!flag;printf "\n"}if(flag)printf $3" "}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find word in a line and output in which line the word occurs / no. of times it occurred

I have a file: file.txt, which contains the following data in it. This is a file, my name is Karl, what is this process, karl is karl junior, file is a test file, file's name is file.txt My name is not Karl, my name is Karl Joey What is your name? Do you know your name and... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

2. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

3. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

4. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

5. Shell Programming and Scripting

How to print last word of line

Hi, How to print last word of line? #!/bin/bash x1="This is Kiran" echo "$x1" how to print "Kiran" in new variable.i.e x2=kiran (7 Replies)
Discussion started by: kiran_j
7 Replies

6. Shell Programming and Scripting

copy line to new file if word matches

I'm drawing blank on this. The log file I have is filled with garbage, but the important lines are ##/##/### Installation xxxxxxx So, I want to sed the line to a new file IF the word installation is in it. I tried removing none matching lines sed 's/Installation/,//!d' infile > outfile but that... (3 Replies)
Discussion started by: dba_frog
3 Replies

7. Shell Programming and Scripting

Using awk to print line starting with particular word

Hi Geeks, Consider this line: driver=c:\folder1\folder2 The above line is contained in a variable say 'var' . I want to copy everything after 'driver=' in to another variable say var2. Please tell me how can this be done. (8 Replies)
Discussion started by: ajincoep
8 Replies

8. Shell Programming and Scripting

Search word in a line and print earlier pattern match

Hi All, I have almost 1000+ files and I want to search specific pattern. Looking forwarded your input. Search for: word1.word2 (Which procedure contain this word, I need procedure name in output. Expected output: procedure test1 procedure test2 procedure test3 procedure test4 ... (7 Replies)
Discussion started by: susau_79
7 Replies

9. Shell Programming and Scripting

Print line if first Field matches a pattern

Hi All, I would like my code to be able to print out the whole line if 1st field has a dot in the number. Sample input and expected output given below. My AWK code is below but it can;t work, can any expert help me ? Thanks in advance. {if ($1 ~ /*\.*/) { print $0 }} Input: ... (2 Replies)
Discussion started by: Raynon
2 Replies

10. Shell Programming and Scripting

print next line if matches a particular word..need help

Hi i need a help for making a script whch can print next line if it matches a particular word like file1 have ename Mohan eid 2008 ename Shyam eid 345 if scipt got Mohan it will print next line (eid 2008) pls help me .......:) (2 Replies)
Discussion started by: anish19
2 Replies
Login or Register to Ask a Question
NG_ETF(4)						   BSD Kernel Interfaces Manual 						 NG_ETF(4)

ng_etf -- Ethertype filtering netgraph node type SYNOPSIS
#include <netgraph.h> #include <netgraph/ng_etf.h> DESCRIPTION
The etf node type multiplexes and filters data between hooks on the basis of the ethertype found in an Ethernet header, presumed to be in the first 14 bytes of the data. Incoming Ethernet frames are accepted on the downstream hook and if the ethertype matches a value which the node has been configured to filter, the packet is forwarded out the hook which was identified at the time that value was configured. If it does not match a configured value, it is passed to the nomatch hook. If the nomatch hook is not connected, the packet is dropped. Packets travelling in the other direction (towards the downstream hook) are also examined and filtered. If a packet has an ethertype that matches one of the values configured into the node, it must have arrived in on the hook for which that value was configured, otherwise it will be discarded. Ethertypes of values other than those configured by the control messages must have arrived via the nomatch hook. HOOKS
This node type supports the following hooks: downstream Typically this hook would be connected to a ng_ether(4) node, using the lower hook. nomatch Typically this hook would also be connected to an ng_ether(4) type node using the upper hook. <any legal name> Any other hook name will be accepted and can be used as the match target of an ethertype. Typically this hook would be attached to a protocol handling node that requires and generates packets with a particular set of ethertypes. CONTROL MESSAGES
This node type supports the generic control messages, plus the following: NGM_ETF_GET_STATUS This command returns a struct ng_etfstat containing node statistics for packet counts. NGM_ETF_SET_FILTER Sets the a new ethertype filter into the node and specifies the hook to and from which packets of that type should use. The hook and ethertype are specified in a structure of type struct ng_etffilter: struct ng_etffilter { char matchhook[NG_HOOKSIZ]; /* hook name */ u_int16_t ethertype; /* catch these */ }; EXAMPLES
Using ngctl(8) it is possible to set a filter in place from the command line as follows: #!/bin/sh ETHER_IF=fxp0 MATCH1=0x834 MATCH2=0x835 cat <<DONE >/tmp/xwert # Make a new ethertype filter and attach to the Ethernet lower hook. # first remove left over bits from last time. shutdown ${ETHER_IF}:lower mkpeer ${ETHER_IF}: etf lower downstream # Give it a name to easily refer to it. name ${ETHER_IF}:lower etf # Connect the nomatch hook to the upper part of the same interface. # All unmatched packets will act as if the filter is not present. connect ${ETHER_IF}: etf: upper nomatch DONE ngctl -f /tmp/xwert # something to set a hook to catch packets and show them. echo "Unrecognised packets:" nghook -a etf: newproto & # Filter two random ethertypes to that hook. ngctl 'msg etf: setfilter { matchhook="newproto" ethertype=${MATCH1} } ngctl 'msg etf: setfilter { matchhook="newproto" ethertype=${MATCH2} } DONE SHUTDOWN
This node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected. SEE ALSO
netgraph(4), ng_ether(4), ngctl(8), nghook(8) HISTORY
The ng_etf node type was implemented in FreeBSD 5.0. AUTHORS
Julian Elischer <> BSD
May 16, 2006 BSD