Simple Text-Processing and -Analytics Command Line Tool made in Python
Explore the code »
Request Feature
·
Report Bug
·
Request Documentation
Table of Contents
- Quick-Find Headers
-
Arguments & Options
- -h, --help
- -v, --version
- --debug, --debug
- -l, --linelength
- -n, --number
- --fp, --file-prefix
- -e, --ends
- --chr, --char
- -b, --blank
- -p, --peek
- -r, --reverse
- -u, --unique
- --sort, --sort
- --sortl, --sortlength
- --sf, --specific-format
- -E, --echo
- -, --stdin
- -o, --oneline
- -U, --url
- -f, --files
- -d, --dirs
- -s, --sum
- -w, --wordcount
- --cc, --charcount
- -g, --grep
- --nk, --nokeyword
- --nb, --nobreak
- -a, --attributes
- -m, --checksum
- --strings, --strings
- --b64d, --b64d
- --b64e, --b64e
- --eval, --EVAL
- --hex, --HEX
- --dec, --DEC
- --oct, --OCT
- --bin, --BIN
- --binview, --binview
- --hexview, --HEXVIEW
- -!, --edit
- -#, --hexedit
- -M, --more
- -L, --less
- -B, --raw
- --visb, --visualizeb
- --visz, --visualizez
- --vish, --visualizeh
- --vise, --visualizee
- --visd, --visualized
- -c, --clip
- --dot, --dotfiles
- --plain, --plain-only
- --nc, --nocolor
- --config, --config
- --cconfig, --cconfig
- --config-clear, --config-reset
- --cconfig-clear, --cconfig-reset
- --config-remove, --cconfig-remove
- -R, --R<stream>
- enc=X, enc꞉X
- find=X, find꞉X
- match=X, match꞉X
- replace=X, replace꞉X
- trunc=X꞉Y, trunc꞉X꞉Y
- [a,b]
- [a꞉b꞉c]
> catw [FILE]... [OPTION]...
> catw --help
> cats [OPTION]...
> cats --help
Argument / Option | Description | REPL supported |
---|---|---|
-h, --help | show help message and exit | ✔ |
-v, --version | output version information and exit | ✔ |
--debug, --debug | show debug information | ✔ |
-l, --linelength | display the length of each line | ✔ |
-n, --number | number all output lines | ✔ |
--fp, --file-prefix | include the file in every line prefix | ❌ |
-e, --ends | mark the end of each line | ✔ |
--chr, --char | display special characters | ✔ |
-b, --blank | hide empty lines | ✔ |
-p, --peek | only print the first and last lines | ❌ |
-r, --reverse | reverse output | ❌ |
-u, --unique | suppress repeated output lines | ❌ |
--sort, --sort | sort all lines alphabetically | ❌ |
--sortl, --sortlength | sort all lines by length | ❌ |
--sf, --specific-format | automatically format specific file types | ❌ |
-E, --echo | handle every following parameter as stdin | ❌ |
-, --stdin | use stdin | ❌ |
-o, --oneline | take only the first stdin-line | ✔ |
-U, --url | display the contents of any provided url | ❌ |
-f, --files | list applied files and file sizes | ❌ |
-d, --dirs | list found directories | ❌ |
-s, --sum | show sum of lines | ❌ |
-w, --wordcount | display the wordcount | ❌ |
--cc, --charcount | display the charcount | ❌ |
-g, --grep | only show lines containing queried keywords or patterns | ✔ |
--nk, --nokeyword | inverse the grep output | ✔ |
--nb, --nobreak | do not interrupt the output | ✔ |
-a, --attributes | show meta-information about the files | ❌ |
-m, --checksum | show the checksums of all files | ❌ |
--strings, --strings | print the sequences of printable characters | ✔ |
--b64d, --b64d | decode the input from base64 | ✔ |
--b64e, --b64e | encode the input to base64 | ✔ |
--eval, --EVAL | evaluate simple mathematical equations | ✔ |
--hex, --HEX | convert hexadecimal numbers to binary, octal and decimal | ✔ |
--dec, --DEC | convert decimal numbers to binary, octal and hexadecimal | ✔ |
--oct, --oct | convert octal numbers to binary, decimal and hexadecimal | ✔ |
--bin, --BIN | convert binary numbers to octal, decimal and hexadecimal | ✔ |
--binview, --binview | display the raw byte representation in binary | ❌ |
--hexview, --HEXVIEW | display the raw byte representation in hexadecimal | ❌ |
-!, --edit | open each file in a simple editor | ❌ |
-#, --hexedit | open each file in a simple hex-editor | ❌ |
-M, --more | page through the file step by step | ❌ |
-L, --less | page through the file step by step (lazy) | ❌ |
-B, --raw | open the file as raw bytes | ❌ |
--visb, --visualizeb | visualize the data using scan curve byte view | ❌ |
--visz, --visualizez | visualize the data using z-order curve byte view | ❌ |
--vish, --visualizeh | visualize the data using hilbert curve byte view | ❌ |
--vise, --visualizee | visualize the data using hilbert curve shannon entropy | ❌ |
--visd, --visualized | visualize the data using digraph dot plot view | ❌ |
-c, --clip | copy output to clipboard | ✔ |
--dot, --dotfiles | additionally query and edit dotfiles | ❌ |
--plain, --plain-only | ignore non-plaintext files automatically | ❌ |
--nc, --nocolor | disable colored output | ✔ |
--config, --config | change default parameters | ✔ |
--cconfig, --cconfig | change color configuration | ✔ |
--config-clear, --config-reset | reset the config to default settings | ✔ |
--cconfig-clear, --cconfig-reset | reset the color config to default settings | ✔ |
--config-remove, --cconfig-remove | remove the config-file | ✔ |
-R, --R<stream> | reconfigure the std-stream(s) with the parsed encoding <stream> = 'in'/'out'/'err' (default is stdin & stdout) |
✔ |
enc=X, enc꞉X | set file enconding to X (default is utf-8) | ✔ |
find=X, find꞉X | find/query a substring X in the given files | ✔ |
match=X, match꞉X | find/query a pattern X in the given files | ✔ |
replace=X, replace꞉X | replace queried substring(s)/pattern(s) in the given files | ✔ |
trunc=X꞉Y, trunc꞉X꞉Y | truncate file to lines X and Y (python-like) | ❌ |
[a,b] | replace a with b in every line | ✔ |
[a꞉b꞉c] | python-like string indexing syntax (line by line) | ✔ |
- Order of Operation
- Files will be used in the same Order as they were provided.
- When passing in a File-pattern or a Directory the Files will be used in the Order in which they were found. This will often be alphabetically, although this is not guaranteed.
- URLs will be used in the Order as they were provided, after all Files have been displayed.
- Arguments will for the most part be used in the same Order as they were provided, yet there are some Exceptions.
- Case-Sensitivity
- The Arguments are Case sensitive.
- Some Arguments have slightly different Behaviour when using Upper- or Lowercase Letters.
- Chaining
- One-letter Arguments can be chained together (e.g.
-l -n -c
is equivalent to-lnc
)
- One-letter Arguments can be chained together (e.g.
- Input Order
- No specific Order for passing in Arguments or Files is neccessary.
- Arguments, Files and Urls may be passed in without any Rules to ordering (e.g. catw file1 -argument url -argument2 file2).
- If the same Argument is passed in multiple times only the first Occurence is being counted.
- Unknown Files
- When encountering unknown Files the User is being prompted to write to StdIn.
- The StdIn is being used to then write the Files.
- When using the -, --stdin Parameter unknown Files will be automatically written with the Content of StdIn.
- Coloring
- The Output will contain Color by Default.
- cat_win will not explicitly add Color if the Argument --nc, --nocolor is used. (The Output may still contain Color if a File itself contains the ANSI-Color-Coding.)
- The Output will be stripped of any Color if the Output is piped and the Configuration
strip_color_on_pipe
is set totrue
.
- Archives
- Archives will not be displayed like regular Files.
- When passing in an Archive the contained Files will be listed along side their File Size instead.
- Currently supported Archive Formats are:
- Zip Formats and Equivalents:
.zip
.egg
.jar
.whl
- Tar and compressed Tar Formats:
.tar
.tar.gz
.tgz
.tar.bz2
.tz2
- Zip Formats and Equivalents:
Displays the help Message. This Message is for the most part equivalent to the Table above. The Code Execution will stop after showing this Message. This Argument has Priority over all other Arguments, hence the Order of passing this Argument in makes no Difference. If no Arguments or Files are provided, the help Parameter will be used by Default.
Displays a short Message containing basic Information about the Code. This includes the version Number but also the installation Directory. The Code Execution will stop after showing this Message.
> catw -v
------------------------------------------------------------------------------
Catw <Version> - from <Path>
------------------------------------------------------------------------------
Built with: Python <PyVersion>
Install time: YYYY-MM-DD HH:MM:SS
Author: Silas A. Kraume
Displays debug Information before and after the Code Execution. This Argument is not shown in the Default Help Message and is provided for Developers/Development.
Displays the Length of each Line as a Prefix to the Line itself. This Argument will be used at the End such that other Arguments may influence the Length of the Lines beforehand.
> catw test.txt -l
[ 6] line 1
[10] long_line!
Numbers all Lines. The Numberisation is done at the Beginning such that different Arguments may disorganize the Numberisation again. Each File starts with line Number 1 therefor multiple Files are not consecutively numbered. If multiple Files are provided, the Prefix will also include the Number of the File.
> catw test.txt -n
1) line 1
2) line 2
> catw test.txt test.txt -n
1.1) line 1
1.2) line 2
2.1) line 1
2.2) line 2
Shows the Path to the File in each Line prefix. This can be useful when querying for Substrings or Patterns such that only a few Lines are being displayed. Using this Argument in Uppercase (--FP, --FILEPREFIX) will result in the Path being shown as the URL File Protocol. This can be useful in Case the Terminal supports interacting with Links such that the File can be instantly opened. Using the Lowercase Argument in Combination with the -n, --number Parameter a GNU-style link format will be displayed.
> catw test.txt --fp
<Path>/test.txt line 1
<Path>/test.txt line 2
> catw test.txt --FP -n
1) file:///<Path>/test.txt line 1
2) file:///<Path>/test.txt line 2
> catw test.txt --fp -n
<Path>/test.txt:1 line 1
<Path>/test.txt:2 line 2
Displays a '$' Character at the End of each Line.
This can be useful to detect Whitespaces.
The Character to display can be configured using the end_marker_symbol
Element in the Config Menu (--config, --config).
> catw test.txt --ends
Tab: $
line 2$
Replaces most special Characters with a readable Token. Each Token starts with the '^' Character, followed by a short ASCII Descriptor. Note that the special Char ␛ will not be displayed as ^ESC because it is needed for the colored Output.
> catw test.txt
����� �
> catw test.txt --chr
^SUB^SUB^NUL^SUB^SUB^TAB^BEL
Removes empty Lines from the Output.
Beware that other Arguments can change a Line to be not empty beforehand.
When toggling the blank_remove_ws_lines
Element in the Config Menu (--config, --config) also Lines which only contain Whitespaces such as Space or Tab will be removed from the Output.
> catw test.txt -nb
1) Empy Line follows:
3) Empty Line just got skipped!
Only displays the first and last 5 Lines of each File.
Between the Beginning and End of the File will be displayed how many Lines have been skipped.
Useful for getting a quick Impression of how Data in a given File is structured.
This Argument is ignored when provided alongside with Queries for Substrings of Patterns or the -M, --more Parameter.
Does nothing when the File has at most 10 Lines.
The peek_size
Element in the Config Menu (--config, --config) defines how many Lines to display.
> catw test.txt -p
Line 1
Line 2
Line 3
Line 4
Line 5
:
10
:
Line 16
Line 17
Line 18
Line 19
Line 20
Simply reverses the Content of all Files as well as the Ordering of all Files themselves.
> catw test1.txt test2.txt -r
Line 2 From Test2
Line 1 From Test2
Line 2 From Test1
Line 1 From Test1
Suppresses repeated Lines if they occur exactly one after the other.
> catw test.txt
This is a line!
This is a line!
This is a line!
This is also a line!
This is a line!
> catw test.txt --unique
This is a line!
This is also a line!
This is a line!
Sorts the Output alphabetically without Case Sensitivity.
> catw test.txt --sort -n
2) A line that has been sorted to the top!
1) This line was originally at the top!
Sorts the Output by Line Length.
> catw test.txt --sortl -l
[13] A short line!
[21] This line was on top!
Automatically format specific File Types.
Currently supported are .json
and .xml
.
> catw --sf -E '{"person":{"name":"Alice","age":25,"employees":[{"name":"Bob"},{"name:":"David"}]}}'
{
"person": {
"name": "Alice",
"age": 25,
"employees": [
{
"name": "Bob"
},
{
"name:": "David"
}
]
}
}
> catw --sf -E '<lib><book id="1"><title>Cats</title></book><book id="2"></book></lib>'
<?xml version="1.0" ?>
<lib>
<book id="1">
<title>Cats</title>
</book>
<book id="2"/>
</lib>
Everything passed in after this Argument will be handled as its own File.
It is not possible to break out of this State therefor this Parameter must be used last.
The Input is unicode-escaped (\n will be interpreted as an actual Newline) if the Config Option unicode_escaped_echo
is set to true
but in Case of an unicode-error the Input will simply be used literally.
This way it is possible to define new Lines (\n) or other special Characters.
> catw -l --echo -n The last 'Parameter' does not count!\nThis is not a newline!
[57] -n The last Parameter does not count!\nThis is not a newline, unless the config option is set!
Using this Argument allows to pass in Data via the StdIn Stream. The StdIn Pipe will be handled as its own File.
> echo Hello World! | catw - -n
1) Hello World!
Limits the StdIn Stream to the first Line. Can only be used in Combination with -, --stdin.
> catw test.txt
Line 1
Line 2
Line 3
> catw test.txt | catw - -o
Line 1
When using this Parameter it is possible to provide URLs as Arguments. Should an URL not have a Scheme (http(s):// or fttp(s):// ...) the Default Scheme (https://) is being used. Provided URLs are simply curl'd and handled as its own File. When not providing a raw Data URL the Content will include the HTML Elements.
> catw -U https://github.com/SilenZcience/cat_win > cat.html
Displays a small Summary at the End of Code Execution showing every File used and their File Size. Using this Argument in Uppercase (-F, --FILES) will ONLY display the Summary and stop Code Execution.
> catw test.txt -f
Line 1
Line 2
applied FILE(s):
13.0 B <Path>/test.txt
Sum: 13.0 B
Amount: 1
> catw test.txt --FILES
found FILE(s):
13.0 B <Path>/test.txt
Sum: 13.0 B
Amount: 1
Displays a small Summary at the End of Code Execution showing every Directory found and their Folder Size. Using this Argument in Uppercase (-D, --DIRS) will ONLY display the Summary and stop Code Execution.
> catw ./** -d
Line 1
Line 2
...
found DIR(s):
<Path>
<Path>/<PathA>
<Path>/<PathA>/<PathAA>
<Path>/<PathB>
Amount: 4
> catw ./** -D
found DIR(s):
<Path>
<Path>/<PathA>
<Path>/<PathA>/<PathAA>
<Path>/<PathB>
Amount: 4
Displays a small Message at the End of Code Execution showing the Number of the Amount of all Lines received. Using this Argument in Uppercase (-S, --SUM) will ONLY show this Message as well as a small Summary. This Summary will show the Line Sum for each File. Duplicate Files will not be displayed multiple times within the Summary. The Uppercase version of this Parameter will stop Code Execution.
> catw test.txt --sum
Line 1
Line 2
Lines (Sum): 2
> catw test.txt test.txt --SUM
File LineCount
<Path>/test.txt 2
Lines (Sum): 4
Displays a Summary of all Tokens/Words found in the given Files and how frequent they occured. The Output will be sorted by the Frequency of Occurrence starting with the most common Word. In Addition the used Files will be displayed beforehand. Using this Argument in Uppercase (-W, --WORDCOUNT) will ONLY display this Message and stop Code Execution.
> catw test.txt
it is true for all that, that that 'that' which that 'that' refers to is not the same 'that' which that 'that' refers to
> catw test.txt -W
The word count includes the following files:
<Path>
that: 9
': 8
is: 2
refers: 2
to: 2
which: 2
,: 1
all: 1
for: 1
it: 1
not: 1
same: 1
the: 1
true: 1
Displays a Summary of all Chars/Letters found in the given Files and how frequent they occured. Whitespace Chars like Spaces and Tabs will be wrapped with quotes. The Output will be sorted by the Frequency of Occurrence starting with the most common Char. In Addition the used Files will be displayed beforehand. Using this Argument in Uppercase (--CC, --CHARCOUNT) will ONLY display this Message and stop Code Execution.
> catw test.txt
it is true for all that, that that 'that' which that 'that' refers to is not the same 'that' which that 'that' refers to
> catw test.txt --CC
The char count includes the following files:
<Path>
t: 24
' ': 23
h: 14
a: 11
': 8
e: 7
r: 6
i: 5
s: 5
o: 4
f: 3
c: 2
l: 2
w: 2
,: 1
m: 1
n: 1
u: 1
Skips every Line that does not contain any matched Patterns or queried Substrings. Literals or Patterns to look for can be set using the find=X, find꞉X and match=X, match꞉X Keywords. Using this Argument in Uppercase (-G, --GREP) will ONLY display the parts of each Line that matched any Pattern or Literal. Should multiple Queries be found in the same Line they will be seperated by Comma. The Uppercase Variant of this Parameter has Priority (over the Lowercase Variant as well as --nk, --nokeyword).
> catw test.txt find=cat -gn
1) cat_win!
4) one cat!& two cat!& three cat
> catw test.txt match=.cat. -Gn
4) cat!, cat!
Inverse to the -g, --grep Argument. Skips every Line that does contain any matched Patterns or queried Substrings. The Combination of --nokeyword and -g, --grep means that no Output will be displayed.
> catw test.txt find=cat -n --nk
2) This Line is boring
3) This Line also does not contain 'c a t'
5) This Line neither
Using this Argument will open non-plaintext Files automatically without prompting the User. In Addition the Output will not stop on queried Substrings or Patterns. This Behaviour is included by Default when using --nk, --nokeyword or -g, --grep.
Shows meta Information for each File provided and stops Code Execution. The meta Information includes file Signature, File Size, Time of Access, -Modified and -Created. On Windows OS Systems this Parameter will also display the classic File Attributes. On Unix Systems this Prameter will also display the classic Group Permissions.
> catw test.txt -a
<Path>/test.txt
Signature: -
Size: 1.55 KB
ATime: YYYY-MM-DD HH:MM:SS.
MTime: YYYY-MM-DD HH:MM:SS.
CTime: YYYY-MM-DD HH:MM:SS.
+Archive, Indexed
-System, Hidden, Readonly, Compressed, Encrypted
> catw test.txt -a
<Path>/test.txt
Signature: -
Size: 1.55 KB
ATime: YYYY-MM-DD HH:MM:SS.
MTime: YYYY-MM-DD HH:MM:SS.
CTime: YYYY-MM-DD HH:MM:SS.
-rwxrwxrwx 1 user user
Shows different Checksums for each File provided and stops Code Execution. The displayed Checksums include CRC32, MD5, SHA1, SHA256 and SHA512.
> catw test.txt -m
Checksum of '<Path>/test.txt':
CRC32: F67C071D
MD5: 95de18c87649e804c15ccdd73ae6eddc
SHA1: cecdcba1cd12a9fdfdb32a1aa1bc40bdb9b1261c
SHA256: 1d4bf9f69b9d1529a5f6231b4edeba61a86deeebf00060c4de6f67f0c4e3b711
SHA512: db9a71ef22360f171daa4e4aed033337f4f97812baf38a51bdd6ed64b5c2a0d4a5c4152e20b68f881df9e5f1087c1293853eac13f928b845b9b71c3ce517c9e3
Only displays Sequences of printable Characters that exceed a certain Length.
This Length can be configured using the strings_minimum_sequence_length
Element in the Config Menu (--config, --config).
The Delimeter of different Sequences on the same Line can be configured using the strings_delimeter
Element in the Config Menu.
> catw --strings test.bin
/lib64/ld-linux-x86-64.so.2
__cxa_finalize
__libc_start_main
puts
libc.so.6
GLIBC_2.2.5
GLIBC_2.34
...
Decodes a Base64 encoded Input and continues Code Execution with the decoded Text. This Parameter will be used before most other Arguments such that other Parameters will be used on the decoded Text. This means a Base64 encoded Input is expected and neccessary.
> echo SGVsbG8gV29ybGQ= | catw - --b64d
Hello World
Encodes a given Text in Base64. This Parameter will be used after most other Arguments such that other Parameter will be used on the plain Text beforehand.
> echo Hello World | catw - --b64e
SGVsbG8gV29ybGQ=
Evaluates simple mathematical Expressions within any given Text. The mathematical Expressions may consist of Paranthesis, Operators including Modulo (%) and Exponential (**), as well as any Number in Hexadecimal, Decimal, Octal or Binary. The evaluated Value of the Expression will by Default be inserted back into the Position of the Text where the Expression was found. In the Uppercase Variant of the Parameter any non-mathematical Text will be stripped thus only evaluated Expressions will remain. On Error The Expression will evaluate to '???'.
> echo Calculate: (5 * 0x10 * -0b101) % (0o5 ** 2) ! | catw - --eval
Calculate: 0 !
> echo Calculate: (5 * 0x10 * -0b101) % (0o5 ** 2) ! | catw - --EVAL
0
If a Line only contains a hexadecimal Number this Parameter will append the equivalent Value in Binary, Octal and Decimal. Negative Numbers are allowed. Numbers are allowed to start with the Prefix 0x. When using the Uppercase Variant (--HEX) the Numbers will not include their Prefixes (like 0x, 0b or 0o).
> catw test.txt --hex
FF [Bin: 0b11111111, Oct: 0o377, Dec: 255]
0x610 [Bin: 0b11000010000, Oct: 0o3020, Dec: 1552]
> catw test.txt --HEX
FF [Bin: 11111111, Oct: 377, Dec: 255]
0x610 [Bin: 11000010000, Oct: 3020, Dec: 1552]
If a Line only contains a decimal Number this Parameter will append the equivalent Value in Binary, Octal and Hexadecimal. Negative Numbers are allowed. When using the Uppercase Variant (--DEC) the Numbers will not include their Prefixes (like 0x, 0b or 0o).
> catw test.txt --dec
255 [Bin: 0b11111111, Oct: 0o377, Hex: 0xff]
1552 [Bin: 0b11000010000, Oct: 0o3020, Hex: 0x610]
> catw test.txt --DEC
255 [Bin: 11111111, Oct: 377, Hex: ff]
1552 [Bin: 11000010000, Oct: 3020, Hex: 610]
If a Line only contains an octal Number this Parameter will append the equivalent Value in Binary, Decimal and Hexadecimal. Negative Numbers are allowed. Numbers are allowed to start with the Prefix 0o. When using the Uppercase Variant (--OCT) the Numbers will not include their Prefixes (like 0x, 0b or 0o).
> catw test.txt --oct
0o377 [Bin: 0b11111111, Dec: 255, Hex: 0xff]
3020 [Bin: 0b11000010000, Dec: 1552, Hex: 0x610]
> catw test.txt --OCT
0o377 [Bin: 11111111, Dec: 255, Hex: ff]
3020 [Bin: 11000010000, Dec: 1552, Hex: 610]
If a Line only contains a binary Number this Parameter will append the equivalent Value in Octal, Decimal and Hexadecimal. Negative Numbers are allowed. Numbers are allowed to start with the Prefix 0b. When using the Uppercase Variant (--BIN) the Numbers will not include their Prefixes (like 0x, 0b or 0o).
> catw test.txt --bin
11111111 [Oct: 0o377, Dec: 255, Hex: 0xff]
0b11000010000 [Oct: 0o3020, Dec: 1552, Hex: 0x610]
> catw test.txt --BIN
11111111 [Oct: 377, Dec: 255, Hex: ff]
0b11000010000 [Oct: 3020, Dec: 1552, Hex: 610]
Displays a Binary View for each File passed in. Special Characters like Newline or Backspace will be displayed as specific readable Chars if the Font and the Encoding do support that Behaviour.
> catw test.txt --binview
<Path>\test.txt:
Address 00 01 02 03 04 05 06 07 08 ... # Decoded Text
00000000 01000011 01100001 01110100 01011111 01010111 01101001 01101110 00100001 00001010 ... # C a t _ W i n ! 
Displays a Hex View for each File passed in. Special Characters like Newline or Backspace will be displayed as specific readable Chars if the Font and the Encoding do support that Behaviour. When using the Uppercase Variant of this Parameter (--HEXVIEW) the hexadecimal Numbers within the Hex View will also be Uppercase.
> catw test.txt --hexview
<Path>\test.txt:
Address 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F # Decoded Text
00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 20 46 72 6f 6d # H e l l o W o r l d F r o m
00000010 20 43 61 74 21 0a # C a t ! 
> catw test.txt --HEXVIEW
<Path>\test.txt:
Address 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F # Decoded Text
00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 20 46 72 6F 6D # H e l l o W o r l d F r o m
00000010 20 43 61 74 21 0A # C a t ! 
Opens a simple Editor to write/edit the Content of any provided File one by one.
Not-existing Files will be opened first and existing Ones will be able to be edited after that.
The Editor will not save Changes automatically.
Files will be saved with the Text Encoding defined by enc=X, enc꞉X.
Note that ^D (Ctrl-D) is reserved for the KeyboardInterrupt meaning that it will stop the entire Program instantly.
The Auto-Indendation Feature can be turned on in the Config Menu using the editor_auto_indent
Element.
The Indendation when using Auto-Indendation can be configured in the Config Menu (--config, --config) using editor_indentation
.
The Input inside the Find Prompt (see Key Bindings) is unicode-escaped (\n will be interpreted as an actual Newline) if the Config Option unicode_escaped_editor_search
is set but in Case of an unicode-error the Input will simply be used literally.
The Input inside the Replace Prompt (see Key Bindings) behaves similiar using the Config Option unicode_escaped_editor_replace
.
On Windows this Feature uses the windows-curses Module.
The currently supported Key Bindings are as follows:
Key(s) | default behaviour | shift click | control click | alt click |
---|---|---|---|---|
Arrows | move cursor by char | select area by char | move cursor by word | scroll window by char |
Page Up/Down | move cursor by page | select area by page | move cursor by page | scroll window by page |
Home/Pos | move cursor to start of line | select area to start of line | move cursor to start of file | scroll window to start of file |
End | move cursor to end of line | select area to end of line | move cursor to end of file | scroll window to end of file |
Tab | insert a tab or indent on empty line |
decrease indent | - | - |
Enter | write newline | write newline | write newline | - |
Backspace | delete char on the left | delete char on the left | delete word on the left | delete char on the left |
Delete | delete char on the right | delete char on the right | delete word on the right | delete char on the right |
Help/F1 | - | - | display a help message | - |
SelectAll/^A | - | - | select the entire file | - |
Copy/^C | - | - | copy selected text | - |
Cut/^X | - | - | cut selected text | - |
Paste/^V | - | - | paste text from clipboard | - |
Undo/^Z | - | - | undo an action | - |
Redo/^Y | - | - | redo an action | - |
Jump/^E | - | - | prompt to jump to specific line | - |
Transform/^T | - | - | transform or question the selected text | - |
Insert/^N | - | - | Insert a byte sequence | toggle action menu switch | - |
Find/^F | - | - | prompt to search in the file | toggle to search regular expressions | - |
QuickFind/F3 | - | jump to the next previous found search-element | jump to the next found search-element | - |
Replace/^P | - | - | prompt to replace a search in the file | toggle to replace all | - |
QuickReplace/F2 | - | replace the next previous found search-element | replace the next found search-element | - |
Save/^S | - | - | save changes | save changes |
Reload/^R | - | - | prompt to reload the file | - |
Background/^B | - | - | put the editor in the background (UNIX only) |
- |
Interrupt/^D | - | - | interrupt program | - |
Quit/^Q | - | - | close editor (prompt to save, if neccessary) |
- |
Transform in the following ways:
capitalize
casefold
lower
lstrip
rstrip
strip
swapcase
title
upper
Question the following attributes:
isalnum
isalpha
isascii
isdecimal
isdigit
isidentifier
islower
isnumeric
isprintable
isspace
istitle
isupper
Opens a simple Hex-Editor to write/edit the Content of any provided File one by one.
Not-existing Files will be opened first and existing Ones will be able to be edited after that.
The Editor will not save Changes automatically.
Note that ^D (Ctrl-D) is reserved for the KeyboardInterrupt meaning that it will stop the entire Program instantly.
The displayed Columns per Row can be configured in the Config Menu (--config, --config) using hex_editor_columns
.
On Windows this Feature uses the windows-curses Module.
The currently supported Key Bindings are as follows:
Key(s) | default behaviour | shift click | control click | alt click |
---|---|---|---|---|
Arrows | move cursor by byte | select area by byte | move cursor multiple bytes | - |
Page Up/Down | move cursor by page | select area by page | move cursor by page | - |
Home/Pos | move cursor to start of line | select area to start of line | move cursor to start of file | - |
End | move cursor to end of line | select area to end of line | move cursor to end of file | - |
0-9 A-F | edit the current byte | - | - | - |
< | insert a new byte to the left | - | - | - |
> ␣ | insert a new byte to the right | - | - | - |
Backspace | reset current byte(s) | reset current byte(s) | remove current byte(s) | reset current byte(s) |
Delete | reset current byte(s) | reset current byte(s) | remove current byte(s) | reset current byte(s) |
Help/F1 | - | - | display a help message | - |
SelectAll/^A | - | - | select the entire file | - |
Copy/^C | - | - | copy selected bytes | - |
Cut/^X | - | - | cut selected bytes | - |
Paste/^V | - | - | overwrite bytes from clipboard or insert text from clipboard | - |
Jump/^E | - | - | prompt to jump to a specific byte | - |
Insert/^N | - | - | insert a text sequence | toggle action menu switch | - |
Find/^F | - | - | prompt to search a byte(-sequence) in the file | toggle to search text | - |
QuickFind/F3 | - | jump to the next previous found search-element | jump to the next found search-element | - |
Save/^S | - | - | save changes | save changes |
Reload/^R | - | - | prompt to reload the file | - |
Background/^B | - | - | put the hex-editor in the background (UNIX only) |
- |
Interrupt/^D | - | - | interrupt program | - |
Quit/^Q | - | - | close hex-editor (prompt to save, if neccessary) |
- |
Page through the File Contents Step by Step.
Each Step the Output is paused until User Interaction.
The first Step always fills the entire Screen.
The following Steps have the Size as defined by the Config Element more_step_length
.
Display the available Commands by entering ?
or h
or help
.
> catw file -M
line 1
line 2
...
line 29
> -- More ( 6%) --
line 30
...
> -- More (11%) --
...
> catw file -M
...
> --More (10%) -- ?
H HELP display this help message
Q QUIT quit
N NEXT skip to next file
L LINE display current line number
D DOWN <x> step x lines down
S SKIP <x> skip x lines
J JUMP <x> jump to line x
...
Page through the File Contents Step by Step.
Each Step the Output is paused until User Interaction.
The first Step always fills the entire Screen.
The following Steps have the Size as defined by the Config Element more_step_length
.
Display the available Commands by entering ?
or h
or help
.
As opposed to the -M, --more Parameter, every other Argument will be ignored and the File will be loaded lazily, resulting in a very fast loading Time (but possibly incorrect Formatting).
> catw file -M
line 1
line 2
...
line 29
> -- More ( 6%) --
line 30
...
> -- More (11%) --
...
> catw file -M
...
> --More (10%) -- ?
H HELP display this help message
Q QUIT quit
N NEXT skip to next file
L LINE display current line number
D DOWN <x> step x lines down
S SKIP <x> skip x lines
J JUMP <x> jump to line x
...
Opens the given Files in Binary Mode.
Prints the Output as Raw Binary to the StdOut Stream.
The only valid Parameters in Combination to -b
, --raw
are --b64e, --b64e, --b64d, --b64d and --strings, --strings.
> catw img.png > copy.png
UnicodeEncodeError: 'charmap' codec can't encode character '\ufffd' in position 0: character maps to <undefined>
...
> catw img.png -R > copy.png
(works but copy.png is corrupted)
> catw img.png --raw > copy.png
⇕
> catw img.png --b64e --raw | catw - --b64d --raw > copy.png
Display the Data of the given Files using a Byte View (Byte by Byte). The Visualization is displayed in a Scan Curve Pattern or Boustrophedon Scan, reversing every other line.
The Width of the Pattern is determined by the Terminal Width. The Byte View classifies Bytes into a small Number of Categories differentiated by Color:
- ⬛: 0x00
- 🟩: Low Bytes / Control Characters
- 🟦: ASCII Text / Printable Characters
- 🟥: High Bytes / Extended Codes
- ⬜: 0xFF
Different File Formats can have different Byte View Characteristics. The Data of the Files used can be limited using the trunc=X꞉Y, trunc꞉X꞉Y Parameter. This way only Chunks/Blocks of a File can be visualized.
Display the Data of the given Files using a Byte View (Byte by Byte). The Visualization is displayed in a Z-Order Curve Pattern. The Width of the Pattern is determined by the Terminal Width. The Byte View classifies Bytes into a small Number of Categories differentiated by Color:
- ⬛: 0x00
- 🟩: Low Bytes / Control Characters
- 🟦: ASCII Text / Printable Characters
- 🟥: High Bytes / Extended Codes
- ⬜: 0xFF
Different File Formats can have different Byte View Characteristics. The Data of the Files used can be limited using the trunc=X꞉Y, trunc꞉X꞉Y Parameter. This way only Chunks/Blocks of a File can be visualized.
Display the Data of the given Files using a Byte View (Byte by Byte). The Visualization is displayed in a Hilbert Curve Pattern. The Width of the Pattern is determined by the Terminal Width. The Byte View classifies Bytes into a small Number of Categories differentiated by Color:
- ⬛: 0x00
- 🟩: Low Bytes / Control Characters
- 🟦: ASCII Text / Printable Characters
- 🟥: High Bytes / Extended Codes
- ⬜: 0xFF
Different File Formats can have different Byte View Characteristics. The Data of the Files used can be limited using the trunc=X꞉Y, trunc꞉X꞉Y Parameter. This way only Chunks/Blocks of a File can be visualized.
Display the Data of the given Files using the Shannon Entropy. The Entropy gets calculated for every Byte using the surrounding 128 Bytes as Frame Size. The Visualization is displayed in a Hilbert Curve Pattern. The Width of the Visualization is determined by the Terminal Width. The Entropy classifies a small Number of Categories differentiated by Color:
- ⬛: Very Low Entropy
- 🟪: Low Entropy
- 🟥: Medium Entropy
- 🟨: High Entropy
- ⬜: Very High Entropy
The Data of the Files used can be limited using the trunc=X꞉Y, trunc꞉X꞉Y Parameter. This way only Chunks/Blocks of a File can be visualized.
Display the Data of the given Files using a Digraph Dot Plot View. The Visualization is displayed on a Square 2D Coordinate System of Length 256x256. The Digraph Dot Plot View visualizes the Byte Distribution by partitioning the Bytes into Pairs with an Offset of One. The Pairs are plotted in the System and therefor display the Quantity of Byte Sequences which often appear next to each other. The relative Frequences of Byte Pairs are classified in a small Number of Categories differentiated by Shading:
- ██ : very high Frequency
- ▓▓ : high Frequency
- ▒▒ : medium Frequency
- ░░ : low Frequency
- ␠␠: very low Frequency
Different File Formats can have different Digraph Dot Plot View Characteristics. The Data of the Files used can be limited using the trunc=X꞉Y, trunc꞉X꞉Y Parameter. This way only Chunks/Blocks of a File can be visualized.
Copies the entire Output to the Clipboard additionally to printing it to the StdOut Stream.
When providing File Patterns or entire Directories cat_win will find every File including those set to hidden (e.g. on Windows OS). However Dotfiles, meaning Files that start with a literal Dot, will not be found by Default. Using this Parameter cat_win will also include Dotfiles.
> catw * -F
found FILE(s):
12.35 KB <Path>/CHANGELOG.md
1.06 KB <Path>/LICENSE
15.07 KB <Path>/README.md
...
> catw * -F --dot
found FILE(s):
969.0 B <Path>/.gitignore
12.35 KB <Path>/CHANGELOG.md
1.06 KB <Path>/LICENSE
15.07 KB <Path>/README.md
...
By Default the User is being prompted when a non-plaintext File is being encountered as to if the File should be opened in Binary or not. Using --plain-only these Files will be automaticaly skipped. Note that these Prompts are not descriptive enough to say that a File can only be opened in Binary. Often the Problem is being fixed by providing another Codepage using the enc=X, enc꞉X Parameter.
By Default different Colors will be used to better highlight specific Parts of the Output or make original and changed Parts of a Line more distinguishable. Using --nocolor will disable all Colors and only display the Output in plain monochrome Text.
Displays a User interactive Config Menu allowing the User to change specific Default Parameters. Stops Code Execution after finishing the Configuration. The Config File will be saved to the installation Directory of cat_win which is by Default the Python Directory. This means that uninstalling cat_win may result in the Config File being left over. When using the Windows Executables this Parameter will have no (long term) Effect. Valid Options are:
Option | Description | Example | Default |
---|---|---|---|
default_command_line | custom Command Line containing Parameters used additionally to the specific Parameters of the Program Call |
-n 'find= ' | |
default_file_encoding | the File Encoding used by Default | utf-16 | utf-8 |
large_file_size | the Size (Bytes) at which a Warning occurs | 1024 | 104857600 (100Mb) |
strip_color_on_pipe | indicate if the Output should be stripped of any Color | false | true |
ignore_unknown_bytes | ignore unknown Bytes instead of replacing them with � | true | false |
end_marker_symbol | define the Marker that will be displayed at EOL when using -e, --ends | ^EOL | $ |
blank_remove_ws_lines | additionally remove whitespace Lines when using -b, --blank | true | false |
peek_size | define the amount of Lines shown by -p, --peek | 10 | 5 |
summary_unique_elements | display only unique elements in summary overviews | true | false |
strings_minimum_sequence_length | set the minimum Length of a String (for the --strings, --strings Parameter) |
2 | 4 |
strings_delimeter | set the Delimeter for Strings found on the same Line (for the --strings, --strings Parameter) |
| | \n |
editor_indentation | set the Indentation used in the Editor (-!, --edit) when pressing ↹ on an empty Line |
␣ ␣ ␣ ␣ | ↹ |
editor_auto_indent | set whether the Editor (-!, --edit) should auto indent or not | true | false |
hex_editor_columns | set the amount of columns per row in the HexEditor (-#, --hexedit) | 8 | 16 |
more_step_length | define the Step Length used by -M, --more a Value of 0 is equivalent to the Size/Height of the Terminal Window |
5 | 0 |
unicode_escaped_echo | unicode-escape the input when using -E, --echo | false | true |
unicode_escaped_editor_search | unicode-escape the Search in the Editor (-!, --edit) | false | true |
unicode_escaped_editor_replace | unicode-escape the Replacement in the Editor (-!, --edit) | false | true |
unicode_escaped_find | unicode-escape the queried Substring when using find=X, find꞉X | false | true |
unicode_escaped_replace | unicode-escape a and b when using [a,b] or replace=X, replace꞉X | false | true |
<NEW CUSTOM COMMAND> | define a custom command/parameter |
Accepted Input for enabling a Setting: true, yes, y, 1
Accepted Input for disabling a Setting: false, no, n, 0
(Input is not case sensitive)
Displays a User interactive Config Menu allowing the User to change the Colors for specific Elements and Arguments.
Stops Code Execution after finishing the Configuration.
The Config File will be saved to the installation Directory of cat_win which is by Default the Python Directory.
This means that uninstalling cat_win may result in the Config File being left over.
When using the Windows Executables this Parameter will have no (long term) Effect.
8-bit Colors can be used by entering the corresponding Color IDs (0-255) with the Prefix f
for Foreground or b
for Background.
24-bit Colors (Truecolor) can be used by entering the RGB values seperated by Comma with the Prefix f
for Foreground or b
for Background.
Thus a valid Input would also be defined by the Format <f/b>[0-255]
or <f/b>[0-255];[0-255];[0-255]
respectively.
Valid Options are:
Option | Description |
---|---|
line_length | the display of each line length using -l, --linelength |
line_numbers | the numbering of each line using -n, --number |
file_prefix | the file prefix using --fp, --file-prefix |
line_ends | the end of line marker using -e, --ends |
special_chars | special chars using --chr, --char |
summary_message | the message displayed using -f, --files/-d, --dirs/-s, --sum/-w, --wordcount/--cc, --charcount |
file_attribute_message | the message containing time stamps and file size using -a, --attributes |
active_file_attributes | the attributes a file has set using -a, --attributes |
missing_file_attributes | the attributes a file has not set using -a, --attributes |
checksum_message | the calculated checksum of a given file using -m, --checksum |
number_evaluation | the evaluated value using --eval, --EVAL |
number_conversion | the converted values using --bin/--oct/--dec/--hex |
raw_viewer | the output using --hexview, --HEXVIEW/--binview, --binview |
found_keyword | the found substring using find=X, find꞉X |
found_keyword_message | the message displayed when using find=X, find꞉X |
matched_pattern | the matched pattern using match=X, match꞉X |
matched_pattern_message | the message displayed when using match=X, match꞉X |
substring_replacement | the replaced string using [a,b] or replace=X, replace꞉X |
progressbar_done | the progress that is already done (displayed when using --vise, --visualizee or reading large files) |
progressbar_missing | the progress that is still missing (displayed when using --vise, --visualizee or reading large files) |
repl_prefix | the prefix displayed when using the cat_win REPL (cats) |
message_information | any informational message like update information |
message_important | any important message like large file sizes |
message_warning | any warning message like overwriting a file with itself |
Reset the Configuration (of --config, --config) to their Default Values.
> catw --config-clear
Successfully updated config file:
<Path>\cat.config
Reset the Configuration (of --cconfig, --cconfig) to their Default Values.
> catw --cconfig-clear
Successfully updated config file:
<Path>\cat.config
Delete the Config File. This will reset both --config, --config and --cconfig, --cconfig Configurations to their Default Values. The cat.config File will be erased from the System.
> catw --config-remove
Successfully removed config file:
<Path>\cat.config
> catw --config-remove
No active config file has been found.
Python uses Utf-8 to encode the Streams by Default. On Windows OS the Encoding may even be Cp1252. The Encoding can be influenced externally by setting the Environment Variable PYTHONIOENCODING to the desired Encoding, or setting the Environment Variable PYTHONUTF8 to 1. In any case it is often useful to have the Stream Encoding Variable if a File for Example is written in another Codepage like Utf-16. Using this Parameter allows for specific Stream Reconfiguration meaning setting the Encoding for interpreting the Streams. The Encoding used is defined by the enc=X, enc꞉X Argument. By Default StdOut and StdErr are reconfigured. Valid Streams are StdOut (--Rout), StdIn (--Rin) and StdErr (--Rerr). When encountering UnicodeErrors the Problem is most likely being fixed by using -R (or --Rout).
> catw ./CHANGELOG.md > test.txt
UnicodeEncodeError: 'charmap' codec can't encode character ...
> catw ./CHANGELOG.md --Rout > test.txt
Sets the Text Encoding that is being used to read and write Files.
Valid Options are defined by the Python Interpreter used (e.g. for Python3.10).
The Default Encoding is Utf-8.
The Default Encoding can be configured using the default_file_encoding
Element in the Config Menu (--config, --config).
> catw test.txt
��This Text is written in Utf-16! d'�
> catw test.txt enc=utf-16
This Text is written in Utf-16! ❤️
Defines a Literal to search for within the Text of any provided File.
The Substring is unicode-escaped (\n will be interpreted as an actual Newline) if the Config Option unicode_escaped_find
is set but in Case of an unicode-error the Substring will simply be used literally.
When the Literal contains Whitespaces it is neccessary to encase the entire Parameter with Quotes as defined by the Terminal used.
It is possible to define multiple Substrings to search for by simply providing the Parameter find=X multiple times.
When using this Parameter in Uppercase the Case of the Substring will be ignored.
Using the shortened Version f=X or f:X yields the same Result.
> catw test.txt "find=cats and"
It's raining cats and dogs!
---------- Found: ('cats and' 13-21) ----------
> catw test.txt "f=CATS and"
It's raining cats and dogs!
> catw test.txt "FIND=CATS and"
It's raining cats and dogs!
---------- Found: ('CATS and' 13-21) ----------
Defines a Pattern to search for within the Text of any provided File. It is possible to define multiple Patterns to match for by simply providing the Parameter match=X multiple times. The given Patterns is simply treated as a regular Expression. When using this Parameter in Uppercase the Case of the Pattern will be ignored. Using the shortened Version m=X or m:X yields the same Result.
> catw test.txt "match=cat.\s.{3,}"
It's raining cats and dogs!
---------- Matched: ('cat.\\s.{3,}' 13-27) ----------
> catw test.txt "m=CAT.\s.{3,}"
It's raining cats and dogs!
> catw test.txt "MATCH=CAT.\s.{3,}"
It's raining cats and dogs!
---------- Matched: ('CAT.\\s.{3,}' 13-27) ----------
Defines a Replacement for queried Literals and Patterns given by find=X, find꞉X and match=X, match꞉X. When defining multiple Replacements only the last one will be used. The Interpretation of the Replacement is dependent on the queried Literal or Pattern. This way regular Expressions can be substituted. Using the shortened Version r=X or r:X yields the same Result.
> catw test.txt "m:([a-z]{3})s" "replace=\\1\\1"
It's raining catcat and dogdog!
> catw test.txt f:and r=or
It's raining cats or dogs!
> catw test.txt "m:([a-z]{3})s" f:and "replace=\\1\\1"
It's raining catcat \1\1 dogdog!
Truncates every File by the Specifics defined. This Parameter uses the Default Python slicing Mechanic and uses it on the Lines of each File. The Argument is valid by defining trunc=<start>:<stop> or trunc=<start>:<stop>:<step>. Using the shortened Version t=X:Y or t:X:Y yields the same Result.
> catw test.txt trunc=5:-5:2
6) Line 6
8) Line 8
10) there are 5 more Lines following this one
Replaces the Substring defined by a with the Substring b in every Line of Every File.
The Substrings a and b are unicode-escaped (\n will be interpreted as an actual Newline) if the Config Option unicode_escaped_replace
is set but in Case of an unicode-error the Substrings will simply be used literally.
Comma (,) can be escaped using \,
despite it not being a valid unicode-escape Sequence.
When one of the Substrings contains Whitespaces it is neccessary to encase the entire Parameter with Quotes as defined by the Terminal used.
> catw test.txt "[\,,X]" "[\\,/]"
This is a comma: X
This is a Backslash: /
Similiar to the trunc=X꞉Y, trunc꞉X꞉Y Parameter yet this Argument is used on each Line individually. Every Line is being cut down as specified by the Elements within the Argument [<start>:<stop>:<step>].
> catw test.txt [2::2]
2468acegikmoqsuwy