Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Find matched pattern and print all based on certain conditions Post 303041538 by bunny_merah19 on Wednesday 27th of November 2019 08:12:57 AM
Old 11-27-2019
Hi,

I noticed that the code did not work for the below condition.

Code:
CL-AS1:4	OnePiece	tra_law	4721	4962	1	.	.	g_id "R06794.16434"; tra_law_id "R06794.16434.1"; g_line "6.980716"; KM "4.794062"; PM"4.235367";
CL-AS1:4	OnePiece	room		4721	4962	1	.	.	g_id "R06794.16434"; tra_law_id "R06794.16434.1"; room_number "1"; g_line "6.980716";
CL-AS1:4	OnePiece	tra_law	5085	5285	1	.	.	g_id "R06794.16435"; tra_law_id "R06794.16435.1"; g_line "4.355471"; KM "2.991154"; PM"2.642568";
CL-AS1:4	OnePiece	room		5085	5285	1	.	.	g_id "R06794.16435"; tra_law_id "R06794.16435.1"; room_number "1"; g_line "4.355471";
CL-AS1:4	OnePiece	tra_law	6800	24864	1	-	.	g_id "R06794.16436"; tra_law_id "R06794.16436.1"; g_line "5.995821"; KM "4.117677"; PM"3.637807";
CL-AS1:4	OnePiece	room		6800	7033	1	-	.	g_id "R06794.16436"; tra_law_id "R06794.16436.1"; room_number "1"; g_line "6.462393";
CL-AS1:4	OnePiece	room		24831	24864	1	-	.	g_id "R06794.16436"; tra_law_id "R06794.16436.1"; room_number "2"; g_line "2.784706";
CL-AS1:4	OnePiece	tra_law	8440	8785	1	.	.	g_id "R06794.16437"; tra_law_id "R06794.16437.1"; g_line "7.209587"; KM "4.951241"; PM"4.374228";
CL-AS1:4	OnePiece	room		8440	8785	1	.	.	g_id "R06794.16437"; tra_law_id "R06794.16437.1"; room_number "1"; g_line "7.209587";

I got the below output. By right, all the data above should be thrown out.

Code:
CL-AS1:4	OnePiece	tra_law	4721	4962	1	.	.	g_id "R06794.16434"; tra_law_id "R06794.16434.1"; g_line "6.980716"; KM "4.794062"; PM"4.235367";
CL-AS1:4	OnePiece	room		4721	4962	1	.	.	g_id "R06794.16434"; tra_law_id "R06794.16434.1"; room_number "1"; g_line "6.980716";
CL-AS1:4	OnePiece	tra_law	5085	5285	1	.	.	g_id "R06794.16435"; tra_law_id "R06794.16435.1"; g_line "4.355471"; KM "2.991154"; PM"2.642568";
CL-AS1:4	OnePiece	room		5085	5285	1	.	.	g_id "R06794.16435"; tra_law_id "R06794.16435.1"; room_number "1"; g_line "4.355471";

Tried to play around with the given codes but it didnt work. Need your kind help again. Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

appending with sed based on matched pattern

Hi, I want to know if you can input with sed but instead of specifing a line number like below I wan't to be able to insert based on a specific word or patttern. 10i\ Insert me after line 10 is this possible with sed or should I use AWK? Thanks Jack (2 Replies)
Discussion started by: jack1981
2 Replies

2. Shell Programming and Scripting

SED: delete and print the only exact matched pattern

I am really need help with the regular expression in SED. From input file, I need to extract lines that have the port number (sport or dport) as defined. The input file is something like this time=1209515280-1209515340 dst=192.168.133.202 src=208.70.8.23 bytes=2472 proto=6 sport=80 dport=1447... (6 Replies)
Discussion started by: new_buddy
6 Replies

3. Shell Programming and Scripting

print last matched pattern using perl

Hi, If there exist multiple pattern in a file, how can I find the last record matching the pattern through perl. The below script searches for the pattern everywhere in an input file. #! /usr/bin/perl -s -wnl BEGIN { $pattern or warn"Usage: $0 -pattern='RE' \n" and exit 255;... (5 Replies)
Discussion started by: er_ashu
5 Replies

4. UNIX for Dummies Questions & Answers

Lynx Grep Pattern Match 2 conditions Print from Start to End

I am working on a scraping project and I am stuck at this tiny grep pattern match. Sample text : FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. ABC Personal Planning Catherine K. Wat Cath Wat Catherine K. Wat Catherine K. Wat IFRAME:... (8 Replies)
Discussion started by: kkiran
8 Replies

5. Linux

Perl program to print previous set of lines once a pattern is matched

Hi all, I have a text data file. My aim here is to find line called *FIELD* AV for every record and print lines after that till *FIELD* RF. But here I want first 3 to four lines for very record as well. FIELD AV is some where in between for very record. SO I am not sure how to retrieve lines in... (2 Replies)
Discussion started by: kaav06
2 Replies

6. Shell Programming and Scripting

print the whole row in awk based on matched pattern

Hi, I need some help on how to print the whole data for unmatched pattern. i have 2 different files that need to be checked and print out the unmatched patterns into a new file. My sample data as follows:- File1.txt Id Num Activity Class Type 309 1.1 ... (5 Replies)
Discussion started by: redse171
5 Replies

7. Shell Programming and Scripting

Print only matched pattern in perl

Hi, I have script like below: #!/usr/local/bin/perl use strict; use warnings; while (<DATA>) { ( my ($s_id) = /^\d+\|(\d+?)\|/ ) ; if ( $s_id == 1 ){ s/^(.*\|)*.*ABC\.pi=(+|+)*.*ABC\.id=(\d+|+).*$/$1$2|$3/s; print "$1$2|$3\n"; (2 Replies)
Discussion started by: sol_nov
2 Replies

8. Shell Programming and Scripting

Print line between two patterns when a certain pattern matched

Hello Friends, I need to print lines in between two string when a keyword existed in those lines (keywords like exception, error, failed, not started etc). for example, input: .. Begin Edr ab12 ac13 ad14 bc23 exception occured bd24 cd34 dd44 ee55 ff66 End Edr (2 Replies)
Discussion started by: EAGL€
2 Replies

9. Shell Programming and Scripting

Regex: print matched line and exact pattern match

Hi experts, I have a file with regexes which is used for automatic searches on several files (40+ GB). To do some postprocessing with the grep result I need the matching line as well as the match itself. I know that the latter could be achieved with grep's -o option. But I'm not aware of a... (2 Replies)
Discussion started by: stresing
2 Replies

10. UNIX for Advanced & Expert Users

To print from the first line until pattern is matched

Hi I want to print the line until pattern is matched. I am using below code: sed -n '1,/pattern / p' file It is working fine for me , but its not working for exact match. sed -n '1,/^LAC$/ p' file Input: LACC FEGHRA 0 LACC FACAF 0 LACC DARA 0 LACC TALAC 0 LAC ILACTC 0... (8 Replies)
Discussion started by: Abhisrajput
8 Replies
NAGZILLAC(1)						      General Commands Manual						      NAGZILLAC(1)

NAME
nagzillac - jabber relay bot client SYNOPSIS
nagzillac type^JID^message DESCRIPTION
This manual page documents briefly the nagzillac command. nagzillac is the client for nagzilla that takes the data you hand it as argument and sends it over to the nagzilla daemon that will send the message along. OPTIONS
nagzillac only takes one options that consists of three arguments. They are seperated by the carret character(`^'), although the last argu- ment may contain carrets without any troubles. Here is an explenation of the different parts: type This is the type of the message. It can be either room (which will send the message to a jabber conference room) or chat (target should be a jabber ID). JID This is the target for the message. If you choose room type it has to be a conference room name or complete ID. A single room with- out any @ in it will get sent to the configured conference server. If you choose the chat type the JID has to be the jabber ID of the user to receive the message, either just the user part which will get added the jabber server as domain part, or a full jabber ID. message The final part is the message that will get sent. At the moment it will be put into the body as plain text. Please notice that you will have to quote or escape special characters in the message like white space. FILES
/etc/nagzillac/nagzillac.cfg The configuration file for the nagzilla client. Please see the comments in the file for informations on what to tweak. EXAMPLE
The following sends a chat message to the rhonda user on the default server: nagzillac "chat^rhonda^hi there" This will send a message to a conference room on a different server: nagzillac "room^monitor@jabber.doma.in^alert - do something" SEE ALSO
nagzillad(1). AUTHOR
nagzillac was written by Bill Mathews. This manual page was written by Gerfried Fuchs <rhonda@debian.at> for the Debian project (and may be used by others). 2009-06-03 NAGZILLAC(1)
All times are GMT -4. The time now is 10:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy