Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1098.Advanced search and replace -- How to insert random lines from one file into another file at random points?

User: editor -- 2013-07-09          << 1097  1099 >>
Hits: 3227
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
How to insert random lines from another file into a target file at random points? 
Input Sample:
source.txt 
The man pointed down the street. 
"Is that your dog?" 
His friend turned and looked. 
"I've never seen it before." 
"Are you sure?" 
"Yes." 
 
insert.txt: 
LINE1. 
LINE2. 
LINE3. 
Output Sample:
target.txt: 
The man pointed down the street. LINE2 
"Is that your dog?" 
His friend turned and looked. 
"I've never seen it before." 
"Are you sure?" LINE1 
"Yes." LINE3 
 
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. Assume insert.txt is in the folder of d:\test\ 
2. ctrl-o open text file 
3. ctrl-h open 'replace' dialogue 
* set 'replace with pattern' to: 
 
* click 'advanced' tab, set 'run following for each matched unit' to: 
 
4. click 'replace', done! 
 
Note:  
* you can modify the number "6" in step 3 to control how many lines you want to insert into target file 
* you can change "$a[$_] $r[$_]" to "$r[$_] $a[$_]" if you want insert text in the start of line.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to insert mulitple text files into multiple html files? (58%)
How to split a 100 line text file into 100 text files? (56%)
After each line, how to insert 1-10 random lines from other files? (56%)
How to split each line of csv file into a single file with specified format? (56%)
How to replace some text with a random line from another file? (56%)
How to save specified lines of text file into different files? (56%)
How to convert multiple files from one encoding to another with online tool? (56%)
How to split a large text file into small files with maximum 1000 lines? (56%)

Check Demo of Advanced search and replace
Keywords:
random point  random points  insert random lines  asp  control  ray  array  insert random  random lines  unique  insert random line from file  insert random lines from each file  insert at start of each line  insert a number each line  replace text from one file to another  how to replace text with text from another file  how to replace text with with from another file  insert one line from each file