Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1210.Text sort -- How to re-arrange lines with in a specified number of lines?

User: Aaron -- 2014-06-30          << 1209  1211 >>
Hits: 1445
Type: Text sort   
Search all Text sort examples
I would like to switch position of lines in a text file within a specific range. For example, every 3 lines, every 7 lines, etc.

Option 1. Choose which lines to switch with other lines in group. E.g. Switch positions of every 1st line with every 3rd, or every 2nd with every 5th etc. within specified range.

Option 2. Randomly shuffle all lines within specified range. E.g. Randomly shuffle all lines within every group of 7 lines.
Input Sample:
Line numbers added to clarify.


I told him all that was in my mind          (1)
He listened without a word.                   (2)
At the end he said he had thought I wanted to be a policeman. (3)
I admitted that I had felt that desire a year ago.            (4)
But I was only seventeen and very immature.                   (5)
So I became a rock star instead.                              (6)
etc.                                                          (7)
Output Sample:
- Chose range of every 3 lines in text

- Switch position of every 1st line with every 3rd.


At the end he said he had thought I wanted to be a policeman. (3)
He listened without a word.                  (2)
I told him all that was in my mind        (1)
So I became a rock star instead.                                             (6)
But I was only seventeen and very immature.                   (5)
I admitted that I had felt that desire a year ago.                        (
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 'replace with pattern' to:

* click 'settings' tab
* check 'Fixed para lines' option in the middle, and set the following entry to 
3. click 'replace', line 1 and line 3 with be exchanged in each group of 3 lines.

To shuffle lines instead, you can keep all above steps, but change 'replace with pattern' to:

Screenshot 1:  Replace_Window

Screenshot 2:  Replace_Window

Similar Examples:
How to keep specified number of lines randomly? (67%)
How to find out all lines that appeared specified number of times? (65%)
How to split a large text file into specified various number of lines? (65%)
How to replace letters with predefined numbers in a text range? (62%)
How to batch replace files with specified format in each line? (62%)
How to create some copies of 2 files with specified names? (62%)
How to extract 5 unique lines from a text file with 30 lines? (62%)
How to pick up paired lines with specified rules in a text files? (61%)

Check Demo of Text sort
switch  5th  shuffle all lines  shuffle lines  shuffle  shuffle line  within  exchange  position  3rd  sort specific text  sort and count each line  replace text in specified range  shuffle lines in the text  shuffle text lines  replace in specified range  shuffle text file  text shuffle