Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1155.Advanced search and replace -- How to random remove x lines from a line range in text file?

User: Aaron -- 2013-12-06          << 1154  1156 >>
Hits: 1134
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
Thanks so much for script 1154. I would like to add the option to randomly delete x lines within a specified range only as per the example below. The example shows only a small line range and it should work on a large range, e.g. between lines 1 and 2,000 etc. also.
Input Sample:
Input Sample:

line 1. aaaaaaaaaaaaa 
line 2. bbbbbbbbbbb 
line 3. ccccccccccccc 
line 4. ddddddddddd 
line 5. eeeeeeeeeeeee 
etc. 
line 10.jjjjjjjjjjjjjjjjjjjj

Remove 2 lines randomly from range of 
lines 1 to 5 only . Lines after 5 
remain.
Output Sample:
line 2. bbbbbbbbbbb 
line 3. ccccccccccccc 
line 4. ddddddddddd 
etc. 
line 10.jjjjjjjjjjjjjjjjjjjj
  
or 

line 1. aaaaaaaaaaaaa 
line 4. ddddddddddd 
line 5. eeeeeeeeeeeee 
etc.
line 10.jjjjjjjjjjjjjjjjjjjj
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 with pattern' to:

* click 'advanced' tab:
set 'run following for each matched unit' to:

3. click 'replace', done.
4. ctrl-s save to file.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to join every n lines into 1 line in a text file? (73%)
How to replace or remove 3 lines randomly in a text file? (72%)
How to remove duplicate lines from a text file? (66%)
How to randomly deletes x number of lines from text files? (65%)
How to extract all lines with specified date range from text file? (65%)
How to remove around 1/2 lines randomly from a large text files? (65%)
How to shuffle all elements in a specified range in text file? (64%)
How to remove all the lines that with odd line number for multiple files? (64%)

Check Demo of Advanced search and replace
Keywords:
within  range  between lines  randomly  script  scrip  scr  random  rando  rand  delete random  delete range lines  replace text in specified range  remove random  replace in specified range  delete text between  split large text file  split large file