Sponsored Content
Top Forums Shell Programming and Scripting match a pattern and print the line once Post 302333485 by dennis.jacob on Monday 13th of July 2009 08:05:03 AM
Old 07-13-2009
Try:

Code:
awk '/cisco:subname/,/\/cisco:subname/ { if ($0 ~ /cisco:meNm/) { print substr($0,13,index($0,"</")-13); exit; } } ' filename

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

match a pattern, print it and the next line

I have a file nbu_faq.txt (Question/answer) which looks like this What I am trying to do is write out each question in a file1.txt and than the question/answer in a file2.txt like this file1.txt Q: What is nbu? Q: What is blablabla...? Q: Why ....? file2.txt Q: What is nbu? A:... (4 Replies)
Discussion started by: nymus7
4 Replies

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

3. UNIX for Dummies Questions & Answers

MATCH A PATTERN AND PRINT A LINE ABOVE AND BELOW

Dear All, Hv a very specific requirement. I have a very large text file and in which I have to match a pattern and insert a line above and below. Eg: My file cat test date1 date2 date3 date4 I need to match 'date3' and insert "Reminder1" above date3 and insert 'reminder2'... (4 Replies)
Discussion started by: gokulj
4 Replies

4. Shell Programming and Scripting

Print Line if next line Match a pattern

Hi All, Does anyone know how to print 1H1A....... in peal script print line ^1H1A....... if next line equal 5R0RECEIPT.... Thank for help:D Cat st.txt 1H1A-IN-11-5410-0009420|1010047766|dsds|1|N|IN|IN|000000|1||N|<<<line match 5R0RECEIPT| 5R0RECEIPT|... (2 Replies)
Discussion started by: kittiwas
2 Replies

5. Shell Programming and Scripting

awk print pattern match line and following lines

Data: Pattern Data Data Data Data Data Data Data Data Data ... With awk, how do I print the pattern matching line, then the subsequent lines following the pattern matching line. Varying number of lines following the pattern matching line. (9 Replies)
Discussion started by: dmesserly
9 Replies

6. Shell Programming and Scripting

Print only next pattern in a line after a pattern match

I have 2013-06-11 23:55:14 1Umexd-0004cm-IG <= user@domain.com I need sed/awk operation on this, so that it should print the very next pattern only after the the pattern mach <= ie only print user@domain.com (7 Replies)
Discussion started by: anil510
7 Replies

7. Shell Programming and Scripting

Multiple pattern match and print the output in a single line

I need to match two patterns in a log file and need to get the next line of the one of the pattern (out of two patterns) that is matched, finally need to print these three values in a single line. Sample Log: 2013/06/11 14:29:04 <0999> (725102) Processing batch 02_1231324 2013/06/11... (4 Replies)
Discussion started by: rpm120
4 Replies

8. Shell Programming and Scripting

Match pattern and print the line number of occurence using awk

Hi, I have a simple problem but i guess stupid enough to figure it out. i have thousands rows of data. and i need to find match patterns of two columns and print the number of rows. for example: inputfile abd abp 123 abc abc 325 ndc ndc 451 mjk lkj... (3 Replies)
Discussion started by: redse171
3 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. 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
Net::CLI::Interact::Manual::Phrasebook(3pm)		User Contributed Perl Documentation	       Net::CLI::Interact::Manual::Phrasebook(3pm)

NAME
Net::CLI::Interact::Manual::Phrasebook - List of Supported CLIs INTRODUCTION
The bundled phrasebook includes support for a variety of network device CLIs. Many were contributed by users of the module. If you set up a new CLI dictionary, please consider contributing it back! The phrasebook specification is given in Net::CLI::Interact::Phrasebook. For each supported CLI, there is a name which must be passed in the "personality" option to Net::CLI::Interact's "new()" method. After that, you can call the included Macros, and the module will use the included Prompt to match the current state of the CLI. More information is available in the Tutorial and Cookbook. Below is a list of all current bundled CLI dictionaries. Each lists its name, the available Prompts, Macros and Continuations, and from which other CLI dictionaries it inherits. IOS # Cisco IOS CatOS # for older, pre-IOS Cisco devices PIXOS # for PIX OS-based devices PIXOS7 # Slightly different commands from other PIXOS versions FWSM # currently the same as 'PIXOS' FWSM3 # for FWSM Release 3.x devices (slightly different to FWSM 2.x) JunOS # Juniper JUNOS support HP # HP support Nortel # Nortel support ExtremeOS # Extreme Networks support Foundry # Foundry/Brocade device support PERSONALITIES
Cisco This personality goes by the name of "cisco" and provides a basis for many other CLI dictionaries. Prompts are "basic", "privileged", "configure", "user", and "pass". Macros are "begin_privileged", "end_privileged", "begin_configure", "end_configure", and "disconnect". CatOS This personality goes by the name of "catos" and inherits from the "cisco" dictionary. Additionally it provides the "privileged" Prompt. Additionally it also provides the "paging" Macro to set the terminal page size. ExtremeOS This personality goes by the name of "extremeos" and inherits from the "cisco" dictionary. Additional Prompts are "basic", "privileged", "configure", "user", and "pass". Additional Macros are "begin_privileged", "end_privileged", and "disconnect". Foundry / Brocade This personality goes by the name of "foundry" and inherits from the "cisco" dictionary. Before connecting to the device you probably want to set the output separator to be: $nci->transport->ors(" "); For users of Net::Appliance::Session this should be: $session_obj->nci->transport->ors(" "); IOS This personality goes by the name of "ios" and inherits from the "cisco" dictionary. Additionally it provides the "paging" Macro to set the terminal page size. HP This personality goes by the name of "hp" and inherits from the "cisco" dictionary. Additionally it provides the "basic" and "user" Prompts. JunOS This personality goes by the name of "junos" and inherits from the "cisco" dictionary. Additionally it provides the "privileged", "configure", and "user" Prompts. Additionally it also provides the "begin_configure" and "paging" Macros. Nortel This personality goes by the name of "nortel" and inherits from the "cisco" dictionary. Additionally it provides the "user" Prompt. PIXOS This personality goes by the name of "pixos" and inherits from the "cisco" dictionary. Additionally it provides the "paging" Macro to set the terminal page size. It can be used in its own right for Cisco PIX firewalls, but is also used as a base for other dictionaries. PIXOS 7 This personality goes by the name of "pixos7" and inherits from the "pixos" dictionary. Additionally it provides the "paging" Macro to set the terminal page size. FWSM This personality goes by the name of "fwsm" and inherits from the "pixos" dictionary. It provides no further functionality, as Cisco FWSM software version 1 and 2 was the same as the PIX OS. FWSM 3 This personality goes by the name of "fwsm3" and inherits from the "pixos" dictionary. Additionally it provides the "paging" Macro to set the terminal page size. perl v5.14.2 2012-06-12 Net::CLI::Interact::Manual::Phrasebook(3pm)
All times are GMT -4. The time now is 02:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy