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
netusage(1)						    BSD General Commands Manual 					       netusage(1)

NAME
netusage -- Display traffic usage statistics about the network SYNOPSIS
netusage [--help] netusage commands [arguments ...] DESCRIPTION
The netusage program interfaces with symptomsd to display and manage network traffic usage statistics. As additional feature of this tool allows for looking up an application or process name using a Mach-O UUID or a PID. NETWORK STATISTICS COMMANDS
The following commands are used to provide different representations of network traffic usage statistics collected on the system. --all-traffic [-p] [-r] [-n name] [-s sortorder] [-d importfile] [-e exportfile] [--unitize] [--compact] [--interactive] [--interval seconds] Display a table listing the total ingress and egress network traffic usage for each application or process categorized by interface. A timestamp of when the first network traffic was observed is also shown. By default, only applications will be shown unless the -p flag is provided. -p Show a list that includes the combination of applications and processes. -r Force a database refresh before showing the list. -n name Only show the application or process matching name. -s sortorder Sort the list according the following available sort orders: t Sort by total network usage. (default) c Sort by cellular interface usage. w Sort by wi-fi interface usage. i Sort by wired interface usage. a Sort by awdl interface usage. e Sort by expensive interface usage. -d importfile Show a traffic usage comparison between the current values and the contents of the file at importfile. -e exportfile Save the current traffic usage values into exportfile. --unitize Show the table values in unitized format (eg. KB/MB/GB). --compact When showing a traffic usage comparison, only list the entries whose values have changed. --interactive Show a traffic usage table that periodically refresh and can be viewed interactively. When an update occurs, the usage value for the application or process that generated network traffic will appear emphasized. You can use the following com- mands to interact with the table. q Quit p Toggles the values between showing raw bytes and unitized format s Change the sort order of the columns r Redraw the screen h Show help Arrow Keys Scroll the list --interval seconds Set the periodic refresh interval to the specified number of seconds. The minimum value is 5 seconds, and the default interval is 15 seconds. (Only valid in interactive mode) MANAGEMENT COMMANDS
These commands are used to manage and reset the collected network traffic usage statistics. --reset-entry [-p] [-n name] Reset the network traffic usage statistics stored for a single entry. Use the -n flag (and optionally the -p flag) to specify the name of the entry. --unitize name Specify the name of the application to reset the network usage statistics. -p Specify a process name instead of an application name. --reset-all Reset the network traffic usage statistics for all the stored entries. OTHER COMMANDS
These are optional utility commands that are available to look up applications or processes. --resolve-uuid uuid Resolve the given mach-O uuid into an application identifier. --resolve-pid pid Resolve the given pid into an application identifier. Darwin May 31, 2019 Darwin