| User: editor -- 2010-02-27 |
| Hits: 113 |
| Type: Advanced search and replace |
| Search all Advanced search and replace examples |
| Description: |
| How to sort the text file by the date at the beginning of each line? |
| Input Sample: |
| 23/Feb/2009 13:22:20 test line1 25/Feb/2009 19:12:20 test line2 08/Jan/2008 08:08:08 test line3 24/Feb/2009 00:03:19 test line4 |
| Output Sample: |
| 08/Jan/2008 08:08:08 test line3 23/Feb/2009 13:22:20 test line1 24/Feb/2009 00:03:19 test line4 25/Feb/2009 19:12:20 test line2 |
| Answer: |
| Hint: You need to Download and install "Replace Pioneer" to finish following steps. |
| 1. ctrl-o open source text file 2. make operation on text file: (1) convert the date to format of YYYY-MM-DD-hh:mm:ss and add to the beginning of line: * ctrl-h open 'Replace' dialog * set 'Replace Unit' to chars * set 'Replace Scope' to Line * set 'Search for pattern' to: * set 'Replace with pattern' to: * click 'Replace', there will be a new format of date added to the beginning of each line (2) sort the text * ctrl-h open 'replace' dialog again * set 'Replace with pattern' to: * click 'Replace', text file will be sorted (3) remove the added date * ctrl-h open 'replace' dialog again * set 'replace unit' to chars * set 'replace scope' to Line * set 'search for pattern' to: * click 'Replace', the added date is removed. Note: the attached 433.rst script contain all 3 steps above |
| Download Script: scripts/433.rst.zip |
Similar Examples: |
| How to insert a word or phrase to the begining of each line? (72%) How to add a line number at the beginning of each line? (71%) How to limit a text file to less than 40 chars each line? (64%) How to change multiple files, adding filename at the beginning of each file? (63%) How to batch insert the filename into the beginning of the file conent? (62%) Is there any way to strip/add the line number at the beginning of each line? (61%) How to sort the lines in a text files by the order of line length? (60%) How to delete all text after the second comma in each line? (58%) |
Check Demo of Advanced search and replace |