pattern matching over multiple lines and deleting the first


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting pattern matching over multiple lines and deleting the first
# 8  
Old 11-06-2009
Or something like this:

Code:
$
$ cat -n tst.log
     1  blah
     2  blah
     3  Uplink traffic:
     4  Downlink traffic:
     5  blah
     6  Uplink traffic:
     7  Downlink traffic:
     8  Uplink traffic:
     9  Dropped packets: 40
    10  Downlink traffic:
    11  blah
    12  blah
$
$ perl -ne 'BEGIN{undef $/} $x=$_; END{$x=~s/Uplink.*?\nDownlink/Downlink/g; print $x}' tst.log
blah
blah
Downlink traffic:
blah
Downlink traffic:
Uplink traffic:
Dropped packets: 40
Downlink traffic:
blah
blah
$
$

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Group Multiple Lines on SINGLE line matching pattern

Hi Guys, I am trying to format my csv file. When I spool the file using sqlplus the single row output is wrapped on three lines. Somehow I managed to format that file and finally i am trying to make the multiple line on single line. The below command is working fine but I need to pass the... (3 Replies)
Discussion started by: RJSKR28
3 Replies

2. 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

3. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies

4. Shell Programming and Scripting

Deleting lines on matching certain pattern

hi I have a large xml file from which i have taken few lines . In this file I have to find for the string </invoices> and check if the 3 rd line after this string does not begin with <portCode> ,then i have to delete the string </invoices> and the next line having the string </shippingBill>... (13 Replies)
Discussion started by: sunnyboy
13 Replies

5. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

6. Shell Programming and Scripting

Deleting a matching string(line) which is also in other lines

Hi, i need help with my shell script I have a file input.txt containing the following contents /. /usr /usr/share /usr/share/doc /usr/share/doc/wine /usr/share/doc/wine/copyright /usr/share/doc/wine/changelog.Debian.gz I need output as /usr/share/doc/wine /usr/share/doc/wine/copyright... (3 Replies)
Discussion started by: Amit0991
3 Replies

7. Shell Programming and Scripting

Multiple pattern matching using awk and getting count of lines

Hi , I have a file which has multiple rows of data, i want to match the pattern for two columns and if both conditions satisfied i have to add the counter by 1 and finally print the count value. How to proceed... I tried in this way... awk -F, 'BEGIN {cnt = 0} {if $6 == "VLY278" &&... (6 Replies)
Discussion started by: aemunathan
6 Replies

8. Shell Programming and Scripting

Deleting lines from a stream after matching a pattern

Hi, I have a requirement to to an ldapsearch and remove the shadow attributes in the output file. What I do is ldapsearch() | operation to remove shadow > FILE The ldapsearch gives output like this(with same line formation): objectClass: FSConfig objectClass: extensibleObject fsCAIP:... (10 Replies)
Discussion started by: lorzinian
10 Replies

9. Shell Programming and Scripting

Finding lines matching the Pattern and their previous lines in a file

Hi, I am trying to locate the occurences of certain pattern like 'Possible network disconnect' in a text file. I can get the actual lines matching the pttern using: grep -w 'Possible network disconnect' file_name. But I am more interested in getting the timing of these events which are... (7 Replies)
Discussion started by: sagarparadkar
7 Replies

10. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies
Login or Register to Ask a Question
gufw(8) 						      System Manager's Manual							   gufw(8)

NAME
Gufw - Graphic user interface for managing ufw DESCRIPTION
Gufw is an easy to use Ubuntu / Linux firewall, powered by ufw. Gufw is an easy, intuitive, way to manage your Ubuntu firewall. It supports common tasks such as allowing or blocking pre-configured, com- mon p2p, or individual ports port(s), and many others! Gufw is powered by ufw. Introduction iptables is already a very powerful tool by itself, but it's syntax can get awkward at times and hard to figure out, so Ubuntu developers decided to make ufw ("The reason ufw was developed is that we wanted to create a server-level firewalling utility that was a little bit more for `human beings`"), which was to be simpler. Now, on the graphical side of things, Firestarer already existed. But why not make an even easier to use GUI for desktop `human beings`, powered by ufw? This is where Gufw comes in. RUN
You can run Gufw in GNOME menu: /System/Administration/Firewall configuration USAGE
BASIC SETTINGS
Gufw has two states: Enabled and disabled. When Gufw is enabled, you can allow/reject/deny all incoming and outgoing connections. ADD PRECONFIGURED RULE(S) You can select between more Programs and Services preconfigured. Once Program/Service can have multiples rules. ADD SIMPLE RULE(S) You can specify the port or service, and protocol to be allowed (allow traffic), reject (reject traffic without reply), denied (deny traf- fic with reply), limit (limit traffic) on the host, or limit an IP or Port (Protecting against brute-force login attacks). The port can be a number of 5 digits, from 1 to 65535. The service can be any of /etc/services file (By example tcpmux, echo, discard, systat...). The protocol can be: 1. TCP: Apply rule for all traffic in protocol TCP. 2. UDP: Apply rule for all traffic in protocol UDP. 3. both: Apply rule for all traffic in protocol TCP and UDP. ADD ADVANCED RULE(S) You can add an advanced rule. You can specify: 1. Protocol: TCP, UDP or both. 2. From IP Addres: You can allow/deny/reject/limit traffic from IP address. Example for a range: 192.168.1.0/9 3. From Port: You can allow/deny/reject/limit traffic from a port. This parameter is optional. The port can be a number of 5 digits, from 1 to 65535. You can use a range ports with this format port1:port2 (by example 3234:3237), or add multiple ports with port1,port2 (by example 3234,3254). 4. To IP Addres: You can allow/deny/limit traffic to an IP address. This parameter is optional. Example for a range: 192.168.1.0/9 5. To Port: You can allow/deny/reject/limit traffic to a Port. This parameter is optional. The port can be a number of 5 digits, from 1 to 65535. You can use a range ports with this format port1:port2 (by example 3234:3237). GENERAL TO PRECONFIGURED
/ SIMPLE / ADVANCED With the extended parameters you can: 1. Insert a rule in a specific row. 2. Set the log level for ufw. REMOVE ONE RULE
Steps: 1. Select a rule in the list. 2. Click in Remove button. You can delete more rules if you select it. RESET CONFIGURATION
You will remove all rules and reset the ufw configuration to intial status (disable)! EDIT PREFERENCES
You can edit your preferences in /Edit/Preferences menu. Preferences: 1. Gufw log: Gufw will register all commands sent to ufw. 2. ufw log: Enable/disable and set the level of the ufw log. 3. Listening Report: Will display the ports on the live system in the listening state for TCP and the open state for UDP. 4. Notification popups: Gufw will notify the new connections in the Listening Report. SEE ALSO
ufw(8) AUTHOR
Gufw is (C) 2008-2011, Marcos Alvarez Costales <https://launchpad.net/~costales>. This manual page was originally written by Marcos Alvarez Costales <https://launchpad.net/~costales>. 13 Feb 2011 gufw(8)