Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1062.Text file parser -- How to extract specified interface and sw from router configuration file?

User: sam -- 2013-03-07          << 1061  1063 >>
Hits: 1510
Type: Text file parser   
Search all Text file parser examples
Description:
the paragraph is always start with "!" end with "!", if the prargraph include
"interface A,B,C or any" (except interface "Block"), it will filter "interface
A,B,C or any" and "sw ac/tr" to a new file. By sequence, the "interface A,B,C or
any" should alway at fist , then "sw ac/tr" follow it. Except "interface
block", it should not explore to the new file
Input Sample:
!
xxx
!
!
interface A
xxx
xxx
sw ac
xxx
!

interface B  
xxx
!

!
sw ac
interface C
sw tr
xxx
!
!
interface Block
xxx
sw tru 
sw ac
!

!
xxx
!
Output Sample:
interface A
sw ac   

interface B


interface C
sw ac   -->  "sw ac/tc" should be 
undter "interface A,B,C or any"
sw tr

        --->there is no "interfac 
Block"
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open text file
2. ctrl-h open 'replace' dialogue
* set 'replace unit' to 'Paragraph'
* set 'search for pattern' to:

* set 'replace with pattern' to:

* uncheck option of 'print unmatched unit'
* click 'settings' tab:
set 'Para start' to 'other': 
set 'Para end' to 'none'
3. click 'replace', done.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Settings_Window


Similar Examples:
How to extract specified lines in different section of text file? (67%)
How to extract specified text followed by 8 digits from text file? (66%)
How to exract specified strings started with www from text file? (66%)
How to extract all specified date format from a text file? (66%)
How to extarct specified pattern by conditions? (65%)
How to extract all lines with specified date range from text file? (63%)
How to extract all specified links from a html file? (62%)
How to extract specified columns from a large pipe separated csv file? (60%)

Check Demo of Text file parser
Keywords:
configuration  tabs  rar  block  abs  except  include  grep  abc  non  extract block of text from file  extract block text file  extract a block of text  extract paragraph from text file  extract paragraph  not include  extract text start with and end with  except search text