Crates.io | aki-resort |
lib.rs | aki-resort |
version | 0.1.25 |
source | src |
created_at | 2021-03-01 11:23:17.278556 |
updated_at | 2024-06-19 16:36:49.392503 |
description | sort lines of text. You can use regex to specify the KEY. |
homepage | |
repository | https://github.com/aki-akaguma/aki-resort |
max_upload_size | |
id | 362159 |
size | 231,863 |
sort lines of text. You can use regex to specify the KEY.
aki-resort --help
Usage:
aki-resort [options]
sort lines of text.
Ordering options:
-r, --reverse reverse the result of comparisons
--according-to <word> sort according to <word>
-h, --head <num> unsort the first <num> lines.
-t, --tail <num> unsort the last <num> lines.
Other options:
--color <when> use markers to highlight the matching strings
-e, --exp <exp> regular expression. sort by the entires match
-u, --unique output only the first line of an equal
--max-buffer <size> max buffer size
-H, --help display this help and exit
-V, --version display version information and exit
Option Parameters:
<word> 'month', 'numeric', 'string', 'time', 'version'
<when> 'always', 'never', or 'auto'
<exp> regular expression, sort by the entires match.
<size> if a reading size is more than <size>, then it is not output,
quit and display error message.
Environments:
AKI_RESORT_COLOR_SEQ_ST color start sequence specified by ansi
AKI_RESORT_COLOR_SEQ_ED color end sequence specified by ansi
Examples:
This sort via utf-8 code:
cat file1.txt | aki-resort
This sort via 1st chunk of numeric character according to numeric:
cat file1.txt | aki-resort -e "[0-9]+" --according-to numeric
This sort via 1st chunk of numeric character according to month:
cat file1.txt | aki-resort -e ":([^:]+)$" --according-to month
This sort via 1st chunk of numeric version character according to version:
cat file1.txt | aki-resort -e "[^:]+:[^:]+:([0-9.]+):" --according-to version
This sort via 1st chunk of numeric time character according to time:
cat file1.txt | aki-resort -e "([0-9]+:([0-9]+:)?[0-9]+(.[0-9]+)?)" --according-to time
cargo install aki-resort
cargo deb
and install .deb into your local repository of debian package.
The input data used in this example looks like this:
cat fixtures/fruit.txt
result output:
Apple:33:3.3:good:Mar
Orange:222:1.1.2:good:Jan
Cherry:4:4:good:Oct
Kiwi:1111:1.1.11:good:Jun
This sort via utf-8 code.
command line:
cat fixtures/fruit.txt | aki-resort
result output:
Apple:33:3.3:good:Mar
Cherry:4:4:good:Oct
Kiwi:1111:1.1.11:good:Jun
Orange:222:1.1.2:good:Jan
This sort via 1st chunk of numeric character according to numeric.
command line:
cat fixtures/fruit.txt | aki-resort -e "[0-9]+" --according-to numeric
result output:
Cherry:4:4:good:Oct
Apple:33:3.3:good:Mar
Orange:222:1.1.2:good:Jan
Kiwi:1111:1.1.11:good:Jun
This sort via 1st capture of version character according to version.
command line:
cat fixtures/fruit.txt | aki-resort -e "^[^:]+:[^:]+:([^:]+)" --according-to version
result output:
Orange:222:1.1.2:good:Jan
Kiwi:1111:1.1.11:good:Jun
Apple:33:3.3:good:Mar
Cherry:4:4:good:Oct
This sort via 1st capture of month character according to month.
command line:
cat fixtures/fruit.txt | aki-resort -e ":([^:]+)$" --according-to month
result output:
Orange:222:1.1.2:good:Jan
Apple:33:3.3:good:Mar
Kiwi:1111:1.1.11:good:Jun
Cherry:4:4:good:Oct
This sort via 1st capture of numeric time character according to time.
command line:
cat fixtures/fruit.txt | aki-resort -e "([0-9]+:([0-9]+:)?[0-9]+(.[0-9]+)?)" --according-to time
result output:
Cherry:4:4:good:Oct
Apple:33:3.3:good:Mar
Orange:222:1.1.2:good:Jan
Kiwi:1111:1.1.11:good:Jun
This sort via 1st chunk of numeric character according to numeric. And the 1st line is the fixed header.
command line:
cat fixtures/fruit_header.txt | aki-resort -e "[0-9]+" --according-to numeric -h 1
result output:
name:number:version:nice:month
Cherry:4:4:good:Oct
Apple:33:3.3:good:Mar
Orange:222:1.1.2:good:Jan
Kiwi:1111:1.1.11:good:Jun
See fn execute()
for this library examples.
This project is licensed under either of
at your option.