Greetings Mofi and UE Fans
I have assembled a list of Macro (surpisingly alot of posts) and Script posts of interest which I am trying to understand.
By answering Mofi's questions above I have ended up writing a more comprehensive spec below.
Any comments or responses greatly appreciated as always.
Target specification for splitting a file by keyword/string
-
Keyword/String by which the file is split should be a literal
- The format of the source file is such that the
Keyword/String will occur at the beginning of line.
- The source file is a series of outputs of show commands from the CLI of a Huawei/Cisco/Juniper router/switch.
- The string will be for the form
<hostname> show command
- Line containing the string should be the first line of next file
- Line ending type of the new files be fixed DOS preferably.
- File names of the new files would ideally a combination of the
source filename as a prefix and
remainder of the line containing the string. (See example below)
- The angled brackets
< and
> would need to be dropped from the filename
- Prefer a leading zero/0 be used in output filenames preceding the numbers 1 to 9. Prefer this to be the case regardless of whether 9 or less files are created during split operation. So numbering would be 2 digits regardless of single or multiple digit numbers.
- Character encoding of the new files not sure. Will read up on what this means. Maybe derived from file to split?
Macro Forum Interesting posts
http://forums.ultraedit.com/how-to-split-a-single-file-into-multiple-text-file-t17844.html
http://forums.ultraedit.com/how-to-split-a-large-file-into-smaller-files-depen-t15397-s15.html
http://forums.ultraedit.com/macro-to-split-a-large-file-and-save-the-new-ones--t15399.html
http://forums.ultraedit.com/how-to-split-a-large-file-into-smaller-files-depen-t15397.html
http://forums.ultraedit.com/splitting-based-on-content-t3710.html
http://forums.ultraedit.com/a-question-about-splitting-files-t3726.html
http://forums.ultraedit.com/splitting-text-file-t3609.html
http://forums.ultraedit.com/spliting-files-saving-but-line-starts-with-same-wo-t2393.html
Script Forum Interesting posts
http://forums.ultraedit.com/how-to-split-a-single-file-into-multiple-several-f-t17170.html
http://forums.ultraedit.com/how-to-split-a-file-with-a-script-based-on-a-speci-t6704.html
Source File Format
Filename name format =
YYYY
-MM
-DD hh
hmm
mss hostname.log
e.g.
2019-10-14 06h51m59 hostname.log
File content format
This would be a series of commands carried out at CLI as shown below (NOTE in preview the full file does not show up here)
<hostname>disp command1
Text output
Text output
Text output
Text output
<hostname>disp command2
Text output
Text output
Text output
Text output
<hostname>disp command3
Text output
Text output
Text output
Text output
<hostname>disp command4
Text output
Text output
Text output
Text output
<hostname>disp command5
Text output
Text output
Text output
Text output
Destination Files Format
Desired output for case above would be 5 files with filename comprised of original filename with suffix being the command in question.
For example above
File 1 name =
2019-10-14 06h51m59 hostname disp command1.log
File1 contents:
<hostname>disp command1
Text output
Text output
Text output
Text output
File 2 name =
2019-10-14 06h51m59 hostname disp command2.log
File2 contents:
<hostname>disp command2
Text output
Text output
Text output
Text output
File 3 name =
2019-10-14 06h51m59 hostname disp command3.log
File3 contents:
<hostname>disp command3
Text output
Text output
Text output
Text output
File 4 name =
2019-10-14 06h51m59 hostname disp command4.log
File4 contents:
<hostname>disp command4
Text output
Text output
Text output
Text output
File 5 name =
2019-10-14 06h51m59 hostname disp command5.log
File5 contents:
<hostname>disp command5
Text output
Text output
Text output
Text output