Sponsored Content
Top Forums Shell Programming and Scripting Remove multiple lines that match pattern Post 302937885 by RudiC on Tuesday 10th of March 2015 11:15:57 AM
Old 03-10-2015
Try
Code:
awk     'function PRTOUT()      {if (SW&&ST) return;
                                 print IN; if (SW) print SW; if (ST) print ST};
         /interface/            {if (NR > 1) PRTOUT();  SW=ST=""; IN=$0}
         /switchport/           {SW=$0}
         /spanning-tree/        {ST=$0}
         END                    {PRTOUT()}
        ' file
interface FastEthernet0/8
 spanning-tree portfast 
interface FastEthernet0/9
 spanning-tree portfast
interface FastEthernet0/10 
 spanning-tree portfast
interface FastEthernet0/12

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenating multiple lines to one line if match pattern

Hi all, I've been working on a script which I have hit a road block now. I have written a script using sed to extract the below data and pumped into another file: Severity............: MAJORWARNING Summary: System temperature is out of normal range. Severity............: MAJORWARNING... (13 Replies)
Discussion started by: phixsius
13 Replies

2. Shell Programming and Scripting

Perl: Printing Multiple Lines after pattern match

Hello People, Need some assistance/guidance. OUTLINE: Two files (File1 and File2) File1 has some ids such as 009463_3922_1827 897654_8764_5432 File2 has things along the lines of: Query= 009463_3922_1827 length=252 (252 letters) More stufff here ... (5 Replies)
Discussion started by: Deep9000
5 Replies

3. Shell Programming and Scripting

Remove lines from batch of files which match pattern

I need to remove all lines which does not match the pattern from a text file (batch of text files). I also need to keep the header line which is the first line of the file. Please can you provide an example for that. I used this to solve half of my work. I was unable to keep the first line of... (3 Replies)
Discussion started by: talktobog
3 Replies

4. Shell Programming and Scripting

shell script: grep multiple lines after pattern match

I have sql file containing lot of queries on different database table. I have to filter specific table queries. Let say i need all queries of test1,test2,test3 along with four lines above it and sql queries can be multi lines or in single line. Input file contains. set INSERT_ID=1; set... (1 Reply)
Discussion started by: mirfan
1 Replies

5. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

6. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

7. Shell Programming and Scripting

Awk-sed help : to remove first and last line with pattern match:

awk , sed Experts, I want to remove first and last line after pattern match "vg" : I am trying : # sed '1d;$d' works fine , but where the last line is not having vg entry it is deleting one line of data. - So it should check for the pattern vg if present , then it should delete the line ,... (5 Replies)
Discussion started by: rveri
5 Replies

8. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

9. Shell Programming and Scripting

Awk; pattern match, remove and re write

the following pattern match works correctly for me awk '/name="Fruits"/{f=1;next} /"name=Vegetables"/{f=0} f' filename This works well for me. Id like to temporarily move the match out of the file ( > newfile) and be able to stick it back in the same place at a later time. Is this... (7 Replies)
Discussion started by: TY718
7 Replies

10. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies
IFCFG-BRIDGE(5) 					       Network configuration						   IFCFG-BRIDGE(5)

NAME
ifcfg-bridge - ethernet bridge interface configuration SYNOPSIS
/etc/sysconfig/network/ifcfg-br* CONFIGURATION
To setup a bridge interface you need a configuration file ifcfg-<interface-name> with the usual network settings. But you must add addi- tional variables: BRIDGE <yes|no> This option must be set to 'yes' to identify this interface as a bridge interface. BRIDGE_PORTS <interface1 interface2 ... interfaceN> This variable contains a space-separated list of N interfaces which take part in the bridging. OPTIONAL VARIABLES
BRIDGE_AGEINGTIME <time> This option sets the ethernet address ageing time, in seconds. After <time> seconds of not having seen a frame coming from a certain address, the bridge will delete that address from the forwarding database. Setting ageing time to zero makes all entries permanent. BRIDGE_FORWARDDELAY <time> Forwarding delay time is the time in seconds spent in each of the listening and learning states before the forwarding state is entered. This delay is so that when a new bridge comes onto a busy network it looks at some traffic before participating. BRIDGE_HELLOTIME <time> Periodically, a hello packet is sent out by the root bridge and the designated bridges. Hello packets are used to communicate information about the topology throughout the entire bridged local area network. BRIDGE_MAXAGE <time> If a another bridge in the spanning tree does not send out a hello packet for a long period of time, it is assumed to be dead. This timeout can be set with this variable. BRIDGE_PATHCOSTS <costs1 costs2 ... costsN> This is a space-separated list of costs corresponding to the interfaces in BRIDGE_PORTS. Each interface in BRIDGE_PORTS could have a different speed and this value is used when deciding which link to use. Faster interfaces should have lower costs. BRIDGE_PORTPRIORITIES <prio1 prio2 ... prioN> This is a space-separated list of priorities corresponding to the interfaces in BRIDGE_PORTS. The priority value is an unsigned 8-bit quantity (a number between 0 and 255), and has no dimension. This metric is used in the designated port and root port selec- tion algorithms. BRIDGE_PRIORITY <priority> This option sets the bridge's priority to <priority>. The priority value is an unsigned 16-bit quantity (a number between 0 and 65535), and has no dimension. Lower priority values are 'better'. The bridge with the lowest priority will be elected 'root bridge'. BRIDGE_STP <on|off> Multiple ethernet bridges can work together to create even larger networks of ethernets using the IEEE 802.1d spanning tree proto- col. This protocol is used for finding the shortest path between two ethernets, and for eliminating loops from the topology. The spanning tree protocol can also be turned off (for those situations where it just doesn't make sense, for example when this linux box is the only bridge on the LAN, or when you know that there are no loops in the topology.) EXAMPLE
Minimal example for a bridge interface on eth0 and eth1, the bridge interface itself is configured via dhcp: ifcfg-br0 STARTMODE='auto' BOOTPROTO='dhcp' BRIDGE='yes' BRIDGE_PORTS='eth0 eth1' BRIDGE_PORTPRIORITIES='50 20' ADDITIONAL INFORMATION
For additional and more general information have a look into <http://linux-net.osdl.org/index.php/Bridge>. BUGS
Please report bugs at <https://bugzilla.novell.com/index.cgi> AUTHOR
Stefan Scheler <sscheler@suse.de> -- ifup-bridge SEE ALSO
ifcfg(5), ifup(8), brctl(8). sysconfig December 2005 IFCFG-BRIDGE(5)
All times are GMT -4. The time now is 05:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy