├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ └── test.yml ├── .gitmodules ├── Dockerfile ├── LICENSE ├── README.md ├── bin ├── addb.egi ├── addl.egi ├── addr.egi ├── addt.egi ├── comb.egi ├── conv.egi ├── crops.egi ├── cycle.egi ├── dropl.egi ├── dropr.egi ├── dupl.egi ├── flat.egi ├── mirror.egi ├── nestl.egi ├── nestr.egi ├── obrev.egi ├── perm.egi ├── slit.egi ├── stairl.egi ├── stairr.egi ├── sublist.egi ├── subset.egi ├── takel.egi ├── takelx.egi ├── taker.egi ├── takerx.egi ├── wrap.egi ├── zniq.egi └── zrep.egi ├── doc └── example.md ├── img └── logo.png ├── install.sh ├── lib └── egzact │ ├── filters.egi │ └── utils.egi ├── package.sh ├── pkg ├── .tar2package.yml ├── egzact.deb └── egzact.rpm ├── test.sh └── test ├── ShTest.sh └── lib ├── filters.egi └── utils.egi /.gitattributes: -------------------------------------------------------------------------------- 1 | *.egi linguist-language=Egison 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: greymd 2 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - 'develop-**' 8 | - 'bugfix/**' 9 | - 'feature/**' 10 | pull_request: 11 | types: 12 | - opened 13 | - synchronize 14 | - reopened 15 | schedule: 16 | - cron: "0 8 * * 6" # UTC 08:00 (Sat) 17 | 18 | jobs: 19 | build: 20 | 21 | runs-on: ubuntu-latest 22 | if: "!contains(github.event.head_commit.message, 'skip ci')" 23 | 24 | steps: 25 | - uses: actions/checkout@v2 26 | - name: Checkout submodules 27 | run: git submodule update --init --recursive 28 | - name: Install egison 29 | run: | 30 | curl --retry 3 -OL https://git.io/egison.x86_64.deb 31 | sudo dpkg -i ./egison.x86_64.deb 32 | - name: Run tests 33 | run: ./test.sh 34 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/shunit2"] 2 | path = test/shunit2 3 | url = https://github.com/kward/shunit2 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM phusion/baseimage:latest 2 | MAINTAINER Yamada, Yasuhiro 3 | ENV DEBFULLNAME="Yamada, Yasuhiro" DEBEMAIL=yamadagrep@gmail.com DEBIAN_FRONTEND=noninteractive 4 | 5 | RUN curl --retry 3 -sfSLO https://github.com/greymd/egzact/releases/download/v2.0.0/egzact-2.0.0.deb && \ 6 | curl --retry 3 -sfSLO https://github.com/egison/egison-package-builder/releases/download/4.0.0/egison-4.0.0.x86_64.deb 7 | 8 | RUN dpkg -i egzact-2.0.0.deb && \ 9 | dpkg -i egison-4.0.0.x86_64.deb 10 | 11 | RUN rm -f egzact-2.0.0.deb && \ 12 | rm -f egison-4.0.0.x86_64.deb && \ 13 | apt clean && \ 14 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro, Yamada 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | [![Build Status](https://github.com/greymd/egzact/workflows/test/badge.svg?branch=master)](https://github.com/greymd/egzact/actions?query=workflow%3Atest) 6 | 7 | # Generate flexible patterns on the shell 8 | 9 | How to utilize it? See [examples](./doc/example.md). 10 | 11 | ## New command line tools with three concepts. 12 | 13 | * Enumeration of various patterns from the standard input. 14 | * Useful equivalents for existent Linux commands (inspired by [nixar](https://github.com/askucher/nixar)). 15 | * Controlling records and fields given by particular separator (inspired by [Open-Usp-Tukubai](https://github.com/usp-engineers-community/Open-usp-Tukubai)). 16 | 17 | ## Installation 18 | 19 | egzact requires [Egison](https://www.egison.org/) version 4.1.2. 20 | Following installation procedure include installation of Egison. 21 | 22 | #### Linux users (RHEL compatible distros) 23 | 24 | ``` 25 | $ sudo yum install https://git.io/egison-4.1.2.x86_64.rpm ## Install Egison 26 | $ sudo yum install https://git.io/egzact-2.1.1.rpm ## Install egzact 27 | ``` 28 | 29 | #### Linux users (Debian base distros) 30 | 31 | ``` 32 | $ wget https://git.io/egison-4.1.2.x86_64.deb 33 | $ sudo dpkg -i egison-4.1.2.x86_64.deb ## Install Egison 34 | $ wget https://git.io/egzact-2.1.1.deb 35 | $ sudo dpkg -i egzact-2.1.1.deb ## Install egzact 36 | ``` 37 | 38 | #### macOS users 39 | 40 | ``` 41 | $ brew install egison/egison/egison ## Install Egison 42 | $ brew install greymd/tools/egzact ## Install egzact 43 | ``` 44 | 45 | # Commands 46 | ## Generate multiple results from whole the STDIN 47 | 48 | ### $ `conv` 49 | Print whole the inputs as multiple rows with given number of cols. 50 | Location of each field is shifted over to the left by comparison with one upper line. 51 | The reason why the name is `conv` is, the behavior looks like the **convolution**. 52 | 53 | ```sh 54 | $ seq 10 | conv 2 55 | 1 2 56 | 2 3 57 | 3 4 58 | 4 5 59 | 5 6 60 | 6 7 61 | 7 8 62 | 8 9 63 | 9 10 64 | 65 | $ yes | awk '$0=NR' | conv 3 | head 66 | 1 2 3 67 | 2 3 4 68 | 3 4 5 69 | 4 5 6 70 | 5 6 7 71 | . 72 | . 73 | . 74 | 75 | ``` 76 | 77 | ### $ `flat` 78 | Print whole the inputs as multiple rows with given number of cols. 79 | In default, it just removes the new lines. 80 | 81 | ```sh 82 | $ seq 10 | flat 83 | 1 2 3 4 5 6 7 8 9 10 84 | ``` 85 | 86 | The behavior is same as `xargs -n N` option. However [Common command line options](#common-command-line-options) like `fs` can be used. 87 | 88 | ```sh 89 | $ seq 10 | flat 2 90 | 1 2 91 | 3 4 92 | 5 6 93 | 7 8 94 | 9 10 95 | 96 | # Comma separeted file 97 | $ cat myfile 98 | AA,AB,AC,AD 99 | BA,BB,BC,BD 100 | CA,CB,CC,CD 101 | DA,DB,DC,DD 102 | 103 | # Field separator(fs) option is useful for keeping comma. 104 | $ cat myfile | flat fs=, 8 105 | AA,AB,AC,AD,BA,BB,BC,BD 106 | CA,CB,CC,CD,DA,DB,DC,DD 107 | ``` 108 | 109 | ### $ `slit` 110 | 111 | Divide whole the inputs into given number of rows. 112 | 113 | ```sh 114 | # Print A to Z with 3 rows. 115 | $ echo {A..Z} | slit 3 116 | A B C D E F G H I 117 | J K L M N O P Q R 118 | S T U V W X Y Z 119 | 120 | # Each line's number of field is adjusted to be near each other as much as possible. 121 | $ echo A B C D | slit 3 122 | A B 123 | C 124 | D 125 | ``` 126 | 127 | ## Generate multiple results per line. 128 | 129 | ### $ `stairl` 130 | 131 | Generate sublist of the fields. 132 | Each result matches to the *left* side of the original input. 133 | In most cases, it looks *stairs*. 134 | 135 | ```sh 136 | $ echo A B C D | stairl 137 | A 138 | A B 139 | A B C 140 | A B C D 141 | ``` 142 | 143 | #### what's going to happen if the input has multiple lines? 144 | 145 | ```sh 146 | $ cat myfile2 147 | AA AB AC AD 148 | BA BB BC BD 149 | CA CB CC CD 150 | 151 | # The command is executed for each line. 152 | $ cat myfile2 | stairl 153 | AA 154 | AA AB 155 | AA AB AC 156 | AA AB AC AD 157 | BA 158 | BA BB 159 | BA BB BC 160 | BA BB BC BD 161 | CA 162 | CA CB 163 | CA CB CC 164 | CA CB CC CD 165 | 166 | # `eos` option is helpful if you want to know where each result is coming from. 167 | $ cat myfile2 | stairl eos=--- 168 | AA 169 | AA AB 170 | AA AB AC 171 | AA AB AC AD 172 | --- 173 | BA 174 | BA BB 175 | BA BB BC 176 | BA BB BC BD 177 | --- 178 | CA 179 | CA CB 180 | CA CB CC 181 | CA CB CC CD 182 | ``` 183 | 184 | ### $ `stairr` 185 | 186 | Generate sublist of the fields. 187 | Results match to the *right* side of the original input. 188 | In most cases, it looks *stairs*. 189 | 190 | ```sh 191 | $ echo A B C D | stairr 192 | D 193 | C D 194 | B C D 195 | A B C D 196 | ``` 197 | 198 | ### $ `sublist` 199 | 200 | Generate all the sublist of the fields. 201 | 202 | ```sh 203 | $ echo A B C D | sublist 204 | A 205 | A B 206 | B 207 | A B C 208 | B C 209 | C 210 | A B C D 211 | B C D 212 | C D 213 | D 214 | ``` 215 | 216 | Whole the results is same as `stairl | stairr` when the duplicated lines can be merged. 217 | 218 | ```sh 219 | $ echo A B C D | stairl | stairr | sort | uniq 220 | A 221 | A B 222 | A B C 223 | A B C D 224 | B 225 | B C 226 | B C D 227 | C 228 | C D 229 | D 230 | 231 | $ echo A B C D | sublist | sort | uniq 232 | A 233 | A B 234 | A B C 235 | A B C D 236 | B 237 | B C 238 | B C D 239 | C 240 | C D 241 | D 242 | ``` 243 | 244 | ### $ `subset` 245 | 246 | Generate all the subsets of the fields. 247 | 248 | ```sh 249 | $ echo A B C D | subset 250 | A 251 | B 252 | C 253 | D 254 | A B 255 | A C 256 | B C 257 | A D 258 | B D 259 | C D 260 | A B C 261 | A B D 262 | A C D 263 | B C D 264 | A B C D 265 | ``` 266 | 267 | ### $ `crops` 268 | Crop all the patterns which matches given string (regular expression). 269 | It includes all the patterns (from shortest to longest match). 270 | 271 | ```sh 272 | $ echo 1110100110 | crops "1.*1" 273 | 11 274 | 111 275 | 11101 276 | 1101 277 | 101 278 | 11101001 279 | 1101001 280 | 101001 281 | 1001 282 | 111010011 283 | 11010011 284 | 1010011 285 | 10011 286 | ``` 287 | 288 | If you want to use normal `grep` command for matching query, `stairr fs="" | stairl fs=""` can works with almost same behavior. In addition, it is faster than `crops` because it works with multi processing. 289 | 290 | ```sh 291 | $ echo 1110100110 | stairr fs="" | stairl fs="" | grep -o '1.*1' | sort | uniq 292 | 1001 293 | 10011 294 | 101 295 | 101001 296 | 1010011 297 | 11 298 | 1101 299 | 1101001 300 | 11010011 301 | 111 302 | 11101 303 | 11101001 304 | 111010011 305 | ``` 306 | 307 | ### $ `cycle` 308 | 309 | Generate all the circulated patterns. 310 | 311 | ```sh 312 | $ echo A B C D E | cycle 313 | A B C D E 314 | B C D E A 315 | C D E A B 316 | D E A B C 317 | E A B C D 318 | ``` 319 | 320 | ### $ `comb` 321 | 322 | Generate **combinations** of N of fields. 323 | 324 | ``` 325 | $ echo A B C D | comb 2 326 | A B 327 | A C 328 | B C 329 | A D 330 | B D 331 | C D 332 | ``` 333 | 334 | ### $ `perm` 335 | 336 | Generate **permutations** of N of fields. 337 | 338 | ```sh 339 | $ echo A B C D | perm 2 340 | A B 341 | A C 342 | B A 343 | A D 344 | B C 345 | C A 346 | B D 347 | C B 348 | D A 349 | C D 350 | D B 351 | D C 352 | ``` 353 | 354 | ### $ `dupl` 355 | 356 | Duplicate lines. 357 | 358 | ```sh 359 | $ echo A B C D | dupl 3 360 | A B C D 361 | A B C D 362 | A B C D 363 | ``` 364 | 365 | ### $ `obrev` 366 | 367 | Show given line and reversed line. 368 | 369 | *Obverse and Reverse* 370 | 371 | ```sh 372 | $ echo A B C D | obrev 373 | A B C D 374 | D C B A 375 | ``` 376 | 377 | 378 | ## Generate single result for each line. 379 | 380 | ### $ `addl` 381 | 382 | Add str to left side of the input. 383 | 384 | *Add* + *L*eft 385 | 386 | ```sh 387 | $ echo abc | addl ABC 388 | ABCabc 389 | ``` 390 | 391 | ### $ `addr` 392 | 393 | Add str to right side of the input. 394 | 395 | *Add* + *R*ight 396 | 397 | ```sh 398 | $ echo abc | addr ABC 399 | abcABC 400 | ``` 401 | 402 | 403 | ### $ `mirror` 404 | 405 | Reverse the order of the field. 406 | 407 | ```sh 408 | $ echo A B C D | mirror 409 | D C B A 410 | ``` 411 | 412 | 413 | ### $ `takel` 414 | 415 | Print first *N* of fields. 416 | 417 | *Take* + *L*eft 418 | 419 | ```sh 420 | $ echo A B C D | takel 3 421 | A B C 422 | ``` 423 | 424 | ### $ `taker` 425 | 426 | Print last *N* of fields. 427 | 428 | *Take* + *R*ight 429 | 430 | ```sh 431 | $ echo A B C D | taker 3 432 | B C D 433 | ``` 434 | 435 | ### $ `takelx` 436 | 437 | Print fields from first one to the one which matches given regular expression. 438 | 439 | *Take* + *L*eft + rege*X* 440 | 441 | ```sh 442 | $ echo QBY JCG FCM PAG TPX BQG UGB | takelx "^P.*$" 443 | QBY JCG FCM PAG 444 | ``` 445 | 446 | ### $ `takerx` 447 | 448 | Print fields from last one to the one which matches given regular expression. 449 | 450 | *Take* + *R*ight + rege*X* 451 | 452 | ```sh 453 | $ echo QBY JCG FCM PAG TPX BQG UGB | takerx "^P.*$" 454 | PAG TPX BQG UGB 455 | ``` 456 | 457 | ### $ `dropl` 458 | 459 | Remove first *N* of fields. 460 | 461 | *Drop* + *L*eft 462 | 463 | ```sh 464 | $ echo QBY JCG FCM PAG TPX BQG UGB | dropl 3 465 | PAG TPX BQG UGB 466 | ``` 467 | 468 | ### $ `dropr` 469 | 470 | Remove last *N* of fields. 471 | 472 | *Drop* + *R*ight 473 | 474 | ```sh 475 | $ echo QBY JCG FCM PAG TPX BQG UGB | dropr 3 476 | QBY JCG FCM PAG 477 | ``` 478 | 479 | ### $ `zrep` 480 | 481 | Extract particular fields which matches given regular expression. 482 | 483 | eg*Z*act + g*REP* 484 | 485 | ```sh 486 | $ echo 1 2 3 4 5 6 7 8 9 10 | zrep "1" 487 | 1 10 488 | ``` 489 | 490 | ### $ `zniq` 491 | 492 | Merge duplicated fields. 493 | 494 | eg*Z*act + u*NIQ* 495 | 496 | ```sh 497 | $ echo aaa bbb ccc aaa bbb | zniq 498 | aaa bbb ccc 499 | ``` 500 | 501 | ### $ `wrap` 502 | 503 | Add particular prefix and suffix to each field in accordance with given argument. 504 | `*` is the placeholder which represents each field. 505 | 506 | ```sh 507 | $ echo aaa bbb ccc | wrap "

*

" 508 |

aaa

bbb

ccc

509 | ``` 510 | 511 | ### $ `nestl` 512 | 513 | Nest all the fields with with given argument. 514 | `*` is the placeholder which represents each field. 515 | First field is the most deeply nested element. 516 | 517 | *Nest* + *L*eft 518 | 519 | ```sh 520 | $ echo aaa bbb ccc | nestl "

*

" 521 |

aaa

bbb

ccc

522 | ``` 523 | 524 | ### $ `nestr` 525 | 526 | Nest all the fields with with given argument. 527 | `*` is the placeholder which represents each field. 528 | Last field is the most deeply nested element. 529 | 530 | *Nest* + *R*ight 531 | 532 | ```sh 533 | $ echo aaa bbb ccc | nestr "

*

" 534 |

aaa

bbb

ccc

535 | ``` 536 | 537 | ## Other commands 538 | 539 | ### $ `addt` 540 | 541 | Add str to top of the input. 542 | 543 | *Add* + *Top* 544 | 545 | ```sh 546 | $ echo abc | addt ABC 547 | ABC 548 | abc 549 | ``` 550 | 551 | ### $ `addb` 552 | 553 | Add str to bottom of the input. 554 | 555 | *Add* + *Bottom* 556 | 557 | ```sh 558 | $ echo abc | addb ABC 559 | abc 560 | ABC 561 | ``` 562 | 563 | ## Common command line options 564 | 565 | ### `fs` 566 | Field separator. 567 | 568 | * Default value is space ` `. 569 | * Format: `fs=STR` 570 | 571 | Example 572 | 573 | ```sh 574 | $ echo "/usr/local/var/" | stairl fs=/ 575 | 576 | /usr 577 | /usr/local 578 | /usr/local/var 579 | /usr/local/var/ 580 | 581 | # In case of empty, each character is regarded as a field. 582 | $ echo "abcdefg" | stairl fs="" 583 | a 584 | ab 585 | abc 586 | abcd 587 | abcde 588 | abcdef 589 | abcdefg 590 | ``` 591 | 592 | ### `ifs` 593 | Input field separator. 594 | If `fs` is already set, this option is primarily used. 595 | 596 | * Default value is space ` `. 597 | * Format: `ifs=STR` 598 | 599 | Example 600 | 601 | ```sh 602 | $ cat myfile3 603 | AA,AB,AC,AD 604 | BA,BB,BC,BD 605 | 606 | # "," separated input -> " " separated output. 607 | $ cat myfile3 | stairr ifs="," 608 | AD 609 | AC AD 610 | AB AC AD 611 | AA AB AC AD 612 | BD 613 | BC BD 614 | BB BC BD 615 | BA BB BC BD 616 | ``` 617 | 618 | ### `ofs` 619 | Output field separator. 620 | If `fs` is already set, this option is primarily used. 621 | 622 | * Default value is space ` `. 623 | * Format: `ofs=STR` 624 | 625 | 626 | Example 627 | 628 | ```sh 629 | $ cat myfile3 630 | AA,AB,AC,AD 631 | BA,BB,BC,BD 632 | 633 | # "," separated input -> "_" separated output. 634 | $ cat myfile3 | cycle ifs="," ofs="_" 635 | AA_AB_AC_AD 636 | AB_AC_AD_AA 637 | AC_AD_AA_AB 638 | AD_AA_AB_AC 639 | BA_BB_BC_BD 640 | BB_BC_BD_BA 641 | BC_BD_BA_BB 642 | BD_BA_BB_BC 643 | 644 | # "," separated input -> tab separated output. 645 | $ cat myfile3 | dupl ifs="," ofs="\t" 2 646 | AA AB AC AD 647 | AA AB AC AD 648 | BA BB BC BD 649 | BA BB BC BD 650 | ``` 651 | 652 | ### `eor` 653 | End of record (a.k.a, row). 654 | Result of each line (record) is separated with new line `\n` in default. 655 | This option changes the string for separating each record. 656 | 657 | * Default value is new line `\n`. 658 | * Format: `eor=STR` 659 | 660 | Example 661 | 662 | ```sh 663 | $ cat myfile4 664 | AA AB AC AD 665 | BA BB BC BD 666 | 667 | $ cat myfile4 | stairl 668 | AA # End of record 669 | AA AB # End of record 670 | AA AB AC # End of record 671 | AA AB AC AD # End of set 672 | BA # End of record 673 | BA BB # End of record 674 | BA BB BC # End of record 675 | BA BB BC BD # End of set 676 | 677 | $ cat myfile4 | stairr eor=" @@@ " 678 | AD @@@ AC AD @@@ AB AC AD @@@ AA AB AC AD 679 | BD @@@ BC BD @@@ BB BC BD @@@ BA BB BC BD 680 | ``` 681 | 682 | ### `eos` 683 | End of set. Set means, **all results generated from single line**, in this manual. 684 | 685 | * Default value is new line `\n`. 686 | * Format: `eos=STR` 687 | 688 | Example 689 | 690 | ```sh 691 | $ cat myfile4 692 | AA AB AC AD 693 | BA BB BC BD 694 | 695 | 696 | $ cat myfile4 | stairl eos="---" 697 | AA 698 | AA AB 699 | AA AB AC 700 | AA AB AC AD 701 | --- 702 | BA 703 | BA BB 704 | BA BB BC 705 | BA BB BC BD 706 | 707 | $ cat myfile4 | stairl eos="---" eor=" @@@ " ofs=" | " 708 | AA @@@ AA | AB @@@ AA | AB | AC @@@ AA | AB | AC | AD 709 | --- 710 | BA @@@ BA | BB @@@ BA | BB | BC @@@ BA | BB | BC | BD 711 | ``` 712 | 713 | ## Tips 714 | A special command line option `each` is available in ``flat``, ``conv`` and ``slit`` commands. 715 | The option changes command's behavior to "each line mode". 716 | In default, those commands handle whole the standard input (STDIN). 717 | However with this option, those commands can read each line and print the result. 718 | 719 | Example 720 | 721 | ```sh 722 | $ cat myfile4 723 | AA AB AC AD 724 | BA BB BC BD 725 | 726 | $ cat myfile4 | flat 3 727 | AA AB AC 728 | AD BA BB 729 | BC BD 730 | 731 | $ cat myfile4 | flat each 3 732 | AA AB AC 733 | AD 734 | BA BB BC 735 | BD 736 | 737 | $ cat myfile4 | conv each 3 eos="---" 738 | AA AB AC 739 | AB AC AD 740 | --- 741 | BA BB BC 742 | BB BC BD 743 | ``` 744 | 745 | ## Uninstall 746 | 747 | ```sh 748 | $ make uninstall 749 | ``` 750 | 751 | # License 752 | ### Software License 753 | This software is released under the MIT License. 754 | See [LICENSE](./LICENSE) 755 | 756 | ### External Library 757 | [UnitTest.hs](./test/UnitTest.hs) is distributed on [egison/egison](https://github.com/egison/egison) under the [MIT license](https://github.com/egison/egison/blob/master/LICENSE). 758 | 759 | ### Logo 760 | 761 | Creative Commons License
The logo is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. 762 | -------------------------------------------------------------------------------- /bin/addb.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterPlain opts arg (stdin ++ [arg]) 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: addb [OPTIONS] string" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo abc | addb ABC" 16 | print " abc" 17 | print " ABC" 18 | -------------------------------------------------------------------------------- /bin/addl.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterAddl (["ifs=", "ofs="] ++ opts) arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: addl [OPTIONS] string" 13 | optionUsage2 14 | print "tldr:" 15 | print " $ echo abc | addl ABC" 16 | print " ABCabc" 17 | -------------------------------------------------------------------------------- /bin/addr.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterAddr (["ifs=", "ofs="] ++ opts) arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: addr [OPTIONS] string" 13 | optionUsage2 14 | print "tldr:" 15 | print " $ echo abc | addr ABC" 16 | print " abcABC" 17 | -------------------------------------------------------------------------------- /bin/addt.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterPlain opts arg ([arg] ++ stdin) 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: addt [OPTIONS] string" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo abc | addt ABC" 16 | print " ABC" 17 | print " abc" 18 | -------------------------------------------------------------------------------- /bin/comb.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsNum $opts $num -> 8 | execution printEachLine filterComb opts (read num) stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: comb [OPTIONS] number" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo A B C D | comb 2" 16 | print " A B" 17 | print " A C" 18 | print " B C" 19 | print " A D" 20 | print " B D" 21 | print " C D" 22 | -------------------------------------------------------------------------------- /bin/conv.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | #"each" :: argsCheckOptsNum $opts $arg -> 8 | execution printEachLine filterConvEach opts (numValidation arg) stdin 9 | | #"each" :: argsCheckOpts $opts -> 10 | execution printEachLine filterConvEach opts 1 stdin 11 | | argsCheckOptsNum $opts $arg -> 12 | execution printWholeInput filterConv opts (numValidation arg) stdin 13 | | argsCheckOpts $opts -> execution printWholeInput filterConv opts 1 stdin 14 | | _ -> usage 15 | 16 | def usage := 17 | do print "Usage: conv [OPTIONS] [number]" 18 | print " conv each [OPTIONS] [number]" 19 | print "Description:" 20 | print " With `each`, it reads & prints results for each line." 21 | optionUsage 22 | print "" 23 | print "tldr:" 24 | print " $ echo A B C D E | conv 2" 25 | print " A B" 26 | print " B C" 27 | print " C D" 28 | print " D E" 29 | -------------------------------------------------------------------------------- /bin/crops.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterCrops (["ifs=", "ofs="] ++ opts) arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: crops [OPTIONS] string" 13 | optionUsage2 14 | print "tldr:" 15 | print " $ echo 1110100110 | crops \"1.*1\"" 16 | print " 11" 17 | print " 111" 18 | print " 11101" 19 | print " 1101" 20 | print " 101" 21 | print " 11101001" 22 | print " 1101001" 23 | print " 101001" 24 | print " 1001" 25 | print " 111010011" 26 | print " 11010011" 27 | print " 1010011" 28 | print " 10011" 29 | -------------------------------------------------------------------------------- /bin/cycle.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOpts $opts -> execution printEachLine filterCycle opts () stdin 8 | | _ -> usage 9 | 10 | def usage := 11 | do print "Usage: cycle [OPTIONS]" 12 | optionUsage 13 | print "tldr:" 14 | print " $ echo A B C D E | cycle" 15 | print " A B C D E" 16 | print " B C D E A" 17 | print " C D E A B" 18 | print " D E A B C" 19 | print " E A B C D" 20 | -------------------------------------------------------------------------------- /bin/dropl.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsNum $opts $num -> 8 | execution printEachLine filterDropl opts (read num) stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: dropl [OPTIONS] number" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo A B C D E | dropl 2" 16 | print " C D E" 17 | -------------------------------------------------------------------------------- /bin/dropr.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsNum $opts $num -> 8 | execution printEachLine filterDropr opts (read num) stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: dropr [OPTIONS] number" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo A B C D E | dropr 2" 16 | print " A B C" 17 | -------------------------------------------------------------------------------- /bin/dupl.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsNum $opts $num -> 8 | execution printEachLine filterDupl opts (read num) stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: dupl [OPTIONS] number" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo A B C D E | dupl 2" 16 | print " A B C D E" 17 | print " A B C D E" 18 | -------------------------------------------------------------------------------- /bin/flat.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | #"each" :: argsCheckOptsNum $opts $arg -> 8 | execution printEachLine filterFlat opts (numValidation arg) stdin 9 | | #"each" :: argsCheckOpts $opts -> 10 | execution printEachLine filterFlat opts ARGMAX stdin 11 | | argsCheckOptsNum $opts $arg -> 12 | execution printWholeInput filterFlat opts (numValidation arg) stdin 13 | | argsCheckOpts $opts -> 14 | execution printWholeInput filterFlat opts ARGMAX stdin 15 | | _ -> usage 16 | 17 | def usage := 18 | do print "Usage: flat [OPTIONS] [number]" 19 | print " flat each [OPTIONS] [number]" 20 | print "Description:" 21 | print " With `each`, it reads & prints results for each line." 22 | optionUsage 23 | print "" 24 | print "tldr:" 25 | print " $ echo A B C D E | flat 2" 26 | print " A B" 27 | print " C D" 28 | print " E" 29 | -------------------------------------------------------------------------------- /bin/mirror.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOpts $opts -> execution printEachLine filterMirror opts () stdin 8 | | _ -> usage 9 | 10 | def usage := 11 | do print "Usage: mirror [OPTIONS]" 12 | optionUsage 13 | print "tldr:" 14 | print " $ echo AAA BBB CCC AAA | mirror" 15 | print " AAA CCC AAA BBB" 16 | -------------------------------------------------------------------------------- /bin/nestl.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterNestl opts arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: nestl [OPTIONS] string" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo AAA BBB CCC | nestl \"

*

\"" 16 | print "

AAA

BBB

CCC

" 17 | -------------------------------------------------------------------------------- /bin/nestr.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterNestr opts arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: nestr [OPTIONS] string" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo AAA BBB CCC | nestr \"

*

\"" 16 | print "

AAA

BBB

CCC

" 17 | -------------------------------------------------------------------------------- /bin/obrev.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOpts $opts -> execution printEachLine filterObrev opts () stdin 8 | | _ -> usage 9 | 10 | def usage := 11 | do print "Usage: obrev [OPTIONS]" 12 | optionUsage 13 | print "tldr:" 14 | print " $ echo A B C D E | obrev" 15 | print " A B C D E" 16 | print " E D C B A" 17 | -------------------------------------------------------------------------------- /bin/perm.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsNum $opts $num -> 8 | execution printEachLine filterPerm opts (read num) stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: perm [OPTIONS] number" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo A B C D | perm 2" 16 | print " A B" 17 | print " A C" 18 | print " B A" 19 | print " A D" 20 | print " B C" 21 | print " C A" 22 | print " B D" 23 | print " C B" 24 | print " D A" 25 | print " C D" 26 | print " D B" 27 | print " D C" 28 | -------------------------------------------------------------------------------- /bin/slit.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | #"each" :: argsCheckOptsNum $opts $arg -> 8 | execution printEachLine filterSlit opts (numValidation arg) stdin 9 | | #"each" :: argsCheckOpts $opts -> 10 | execution printEachLine filterSlit opts ARGMAX stdin 11 | | argsCheckOptsNum $opts $arg -> 12 | execution printWholeInput filterSlit opts (numValidation arg) stdin 13 | | argsCheckOpts $opts -> 14 | execution printWholeInput filterSlit opts ARGMAX stdin 15 | | _ -> usage 16 | 17 | def usage := 18 | do print "Usage: slit [OPTIONS] [number]" 19 | print " slit each [OPTIONS] [number]" 20 | print "Description:" 21 | print " With `each`, it reads & prints results per line." 22 | optionUsage 23 | print "" 24 | print "tldr:" 25 | print " $ echo A B C D E | slit 2" 26 | print " A B C" 27 | print " D E" 28 | -------------------------------------------------------------------------------- /bin/stairl.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOpts $opts -> execution printEachLine filterStairl opts () stdin 8 | | _ -> usage 9 | 10 | def usage := 11 | do print "Usage: stairl [OPTIONS]" 12 | optionUsage 13 | print "tldr:" 14 | print " $ echo A B C D | stairl" 15 | print " A" 16 | print " A B" 17 | print " A B C" 18 | print " A B C D" 19 | -------------------------------------------------------------------------------- /bin/stairr.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOpts $opts -> execution printEachLine filterStairr opts () stdin 8 | | _ -> usage 9 | 10 | def usage := 11 | do print "Usage: stairr [OPTIONS]" 12 | optionUsage 13 | print "tldr:" 14 | print " $ echo A B C D | stairr" 15 | print " D" 16 | print " C D" 17 | print " B C D" 18 | print " A B C D" 19 | -------------------------------------------------------------------------------- /bin/sublist.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOpts $opts -> execution printEachLine filterSublist opts () stdin 8 | | _ -> usage 9 | 10 | def usage := 11 | do print "Usage: sublist [OPTIONS]" 12 | optionUsage 13 | print "tldr:" 14 | print " $ echo A B C D | sublist" 15 | print " A" 16 | print " A B" 17 | print " B" 18 | print " A B C" 19 | print " B C" 20 | print " C" 21 | print " A B C D" 22 | print " B C D" 23 | print " C D" 24 | print " D" 25 | -------------------------------------------------------------------------------- /bin/subset.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOpts $opts -> execution printEachLine filterSubset opts () stdin 8 | | _ -> usage 9 | 10 | def usage := 11 | do print "Usage: subset [OPTIONS]" 12 | optionUsage 13 | print "tldr:" 14 | print " $ echo A B C D | subset" 15 | print " A" 16 | print " B" 17 | print " C" 18 | print " D" 19 | print " A B" 20 | print " A C" 21 | print " B C" 22 | print " A D" 23 | print " B D" 24 | print " C D" 25 | print " A B C" 26 | print " A B D" 27 | print " A C D" 28 | print " B C D" 29 | print " A B C D" 30 | -------------------------------------------------------------------------------- /bin/takel.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsNum $opts $num -> 8 | execution printEachLine filterTakel opts (read num) stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: takel [OPTIONS] number" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo A B C D E | takel 2" 16 | print " A B" 17 | -------------------------------------------------------------------------------- /bin/takelx.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterTakelx opts arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: takelx [OPTIONS] string" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo QBY JCG FCM PAG TPX BQG UGB | takelx \"^P.*$\"" 16 | print " QBY JCG FCM PAG" 17 | -------------------------------------------------------------------------------- /bin/taker.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsNum $opts $num -> 8 | execution printEachLine filterTaker opts (read num) stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: taker [OPTIONS] number" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo A B C D E | taker 2" 16 | print " D E" 17 | -------------------------------------------------------------------------------- /bin/takerx.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterTakerx opts arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: takerx [OPTIONS] string" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo QBY JCG FCM PAG TPX BQG UGB | takerx \"^P.*$\"" 16 | print " PAG TPX BQG UGB" 17 | -------------------------------------------------------------------------------- /bin/wrap.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterWrap opts arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: wrap [OPTIONS] string" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo AAA BBB CCC | wrap \"

*

\"" 16 | print "

AAA

BBB

CCC

" 17 | -------------------------------------------------------------------------------- /bin/zniq.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOpts $opts -> execution printEachLine filterZniq opts () stdin 8 | | _ -> usage 9 | 10 | def usage := 11 | do print "Usage: zniq [OPTIONS]" 12 | optionUsage 13 | print "tldr:" 14 | print " $ echo aaa bbb ccc aaa bbb | zniq" 15 | print " aaa bbb ccc" 16 | -------------------------------------------------------------------------------- /bin/zrep.egi: -------------------------------------------------------------------------------- 1 | loadFile "../lib/egzact/utils.egi" 2 | 3 | loadFile "../lib/egzact/filters.egi" 4 | 5 | def main := 6 | \match as list string with 7 | | argsCheckOptsStr $opts $arg -> 8 | execution printEachLine filterZrep opts arg stdin 9 | | _ -> usage 10 | 11 | def usage := 12 | do print "Usage: zrep [OPTIONS] string" 13 | optionUsage 14 | print "tldr:" 15 | print " $ echo 1 2 3 4 5 6 7 8 9 10 | zrep \"1\"" 16 | print " 1 10" 17 | -------------------------------------------------------------------------------- /doc/example.md: -------------------------------------------------------------------------------- 1 | # "egzact" Examples 2 | 3 | ## Enumerate all the possible parent domains from the sub domain. 4 | 5 | Command: `stairr` 6 | 7 | ```bash 8 | $ echo hoge.huga.pre.cure.example.com | stairr fs=. 9 | com 10 | example.com 11 | cure.example.com 12 | pre.cure.example.com 13 | huga.pre.cure.example.com 14 | hoge.huga.pre.cure.example.com 15 | ``` 16 | 17 | ## Enumerate all the possible parent directories from the sub directory. 18 | 19 | Command: `stairl` 20 | 21 | ```bash 22 | $ pwd | stairl fs=/ 23 | /usr 24 | /usr/local 25 | /usr/local/bin 26 | ``` 27 | 28 | ## Enumerate all the possible FQDN 29 | 30 | Command: `stairr` `stairl` 31 | 32 | ```bash 33 | $ echo aaa.bbb.ccc.example.com/a/b/c/d | stairr fs=. | stairl fs=/ 34 | com 35 | com/a 36 | com/a/b 37 | com/a/b/c 38 | com/a/b/c/d 39 | example.com 40 | example.com/a 41 | example.com/a/b 42 | example.com/a/b/c 43 | example.com/a/b/c/d 44 | ccc.example.com 45 | ccc.example.com/a 46 | ccc.example.com/a/b 47 | ccc.example.com/a/b/c 48 | ccc.example.com/a/b/c/d 49 | bbb.ccc.example.com 50 | bbb.ccc.example.com/a 51 | bbb.ccc.example.com/a/b 52 | bbb.ccc.example.com/a/b/c 53 | bbb.ccc.example.com/a/b/c/d 54 | aaa.bbb.ccc.example.com 55 | aaa.bbb.ccc.example.com/a 56 | aaa.bbb.ccc.example.com/a/b 57 | aaa.bbb.ccc.example.com/a/b/c 58 | aaa.bbb.ccc.example.com/a/b/c/d 59 | ``` 60 | 61 | ## Enumerate all the `that ... that` parts from [the word sequence](https://en.wikipedia.org/wiki/That_that_is_is_that_that_is_not_is_not_is_that_it_it_is) . 62 | 63 | Command: `stairr` `stairl` 64 | 65 | ``stairl | stairr`` generates all the sublists from the input. 66 | 67 | ```bash 68 | $ echo "That that is is that that is not is not is that it it is" | stairl | stairr | grep -o "that.*that" | sort | uniq 69 | that is is that 70 | that is is that that 71 | that is is that that is not is not is that 72 | that is not is not is that 73 | that that 74 | that that is not is not is that 75 | ``` 76 | 77 | ## Split the file into 17 indivisual files. 78 | 79 | Command: `slit` 80 | 81 | ```sh 82 | $ seq $(awk 'END{print NR}' mytext) | slit 17 | awk '{print "sed -n "$1","$NF"p mytext > mytext."NR}' 83 | sed -n 1,2p mytext > mytext.1 84 | sed -n 3,4p mytext > mytext.2 85 | sed -n 5,6p mytext > mytext.3 86 | sed -n 7,8p mytext > mytext.4 87 | sed -n 9,10p mytext > mytext.5 88 | sed -n 11,12p mytext > mytext.6 89 | sed -n 13,14p mytext > mytext.7 90 | sed -n 15,15p mytext > mytext.8 91 | sed -n 16,16p mytext > mytext.9 92 | sed -n 17,17p mytext > mytext.10 93 | sed -n 18,18p mytext > mytext.11 94 | sed -n 19,19p mytext > mytext.12 95 | sed -n 20,20p mytext > mytext.13 96 | sed -n 21,21p mytext > mytext.14 97 | sed -n 22,22p mytext > mytext.15 98 | sed -n 23,23p mytext > mytext.16 99 | sed -n 24,24p mytext > mytext.17 100 | 101 | # Execute 102 | $ seq $(awk 'END{print NR}' mytext) | slit 17 | awk '{print "sed -n "$1","$NF"p mytext > mytext."NR}' | sh 103 | ``` 104 | 105 | ## Generate [Bi-gram](https://en.wikipedia.org/wiki/N-gram) from the poem. 106 | 107 | Command: `conv` 108 | 109 | ```bash 110 | $ echo "If a man understands a poem, he shall have troubles." | conv 2 111 | If a 112 | a man 113 | man understands 114 | understands a 115 | a poem, 116 | poem, he 117 | he shall 118 | shall have 119 | have troubles. 120 | ``` 121 | 122 | ## Create a zip file nested 100 times. 123 | 124 | Command: `conv` `mirror` `addl` 125 | 126 | ```bash 127 | $ echo file {1..100}.zip | conv 2 | mirror | addl "zip " 128 | zip 1.zip file 129 | zip 2.zip 1.zip 130 | zip 3.zip 2.zip 131 | zip 4.zip 3.zip 132 | zip 5.zip 4.zip 133 | zip 6.zip 5.zip 134 | zip 7.zip 6.zip 135 | zip 8.zip 7.zip 136 | zip 9.zip 8.zip 137 | zip 10.zip 9.zip 138 | ... 139 | 140 | # Execute 141 | $ echo file {1..100}.zip | conv 2 | mirror | addl "zip " | sh 142 | 143 | $ unzip -Z -2 100.zip 144 | 99.zip 145 | ``` 146 | 147 | ## Calculate the approximation of Napier's Constant 148 | 149 | Command: `flat` `stairl` `wrap` `addl` 150 | 151 | ```bash 152 | $ seq 10 | flat | stairl ofs="*" | flat | wrap ofs="+" '1/(*)' | addl "1+" | bc -l 153 | 2.71828180114638447967 154 | ``` 155 | 156 | ## Calculate the approximation of PI 157 | 158 | Command: `addr` `mirror` `flat` `nestr` `wrap` 159 | 160 | ```bash 161 | $ seq 1 2 50 | nl | awk '$1=$1"^2/"' | addr '+' | mirror | flat | addr ' 1' | nestr '(*)' | wrap ifs="_" '(4/ *)' | bc -l 162 | 3.14159265358979323651 163 | ``` 164 | 165 | ## Generate too nexted DOM element 166 | 167 | Command: `nestr` 168 | 169 | ```bash 170 | $ echo {1..10} | nestr "

*

" 171 |

1

2

3

4

5

6

7

8

9

10

172 | ``` 173 | 174 | ## Generate too nexted JSON element 175 | 176 | Command: `wrap` `addr` `nestr` 177 | 178 | `jq` command is necessary. 179 | 180 | ```bash 181 | $ echo A B C D E F | wrap '"*":' | addr "\"G\"" | nestr "{*}" | jq . 182 | { 183 | "A": { 184 | "B": { 185 | "C": { 186 | "D": { 187 | "E": { 188 | "F": "G" 189 | } 190 | } 191 | } 192 | } 193 | } 194 | } 195 | ``` 196 | 197 | ## Easily create the table DOM element from the space separated input. 198 | 199 | Command: `wrap` `flat` `addt` `addb` 200 | 201 | ``` 202 | $ COL=3 203 | $ echo A B C D E F G H | wrap '*' | flat $COL | wrap fs=_ '*' | addt '' | addb '
' 204 | 205 | 206 | 207 | 208 |
A B C
D E F
G H
209 | ``` 210 | -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greymd/egzact/3f3c5661e5bdf60e663436d1185364e20341eeb4/img/logo.png -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ue 3 | 4 | readonly THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%N}}")" && pwd)" 5 | readonly BINMODE=755 6 | readonly LIBMODE=644 7 | readonly SRCMODE=644 8 | readonly PREFIX="${1:-/usr/local}" 9 | readonly PREFIX_BIN="${PREFIX}/bin" 10 | readonly PREFIX_LIB="${PREFIX}/lib/egzact" 11 | readonly PREFIX_SRC="${PREFIX}/lib/egzact/src" 12 | 13 | _installbin () { 14 | local _mode="$1" ;shift 15 | local _src="$1" ;shift 16 | local _dst="$1" ;shift 17 | cat <