@@ -26,9 +26,9 @@ To include this file in your own script, in the same directory:
2626## Tracking
2727
2828* Package: posix-shell-script-kit
29- * Version: 11.0.5
29+ * Version: 11.1.0
3030* Created: 2017-08-22T00:00:00Z
31- * Updated: 2023-03-24T13:23:36Z
31+ * Updated: 2023-03-28T14:01:52Z
3232* Website: https://github.com/sixarm/posix-shell-script-kit
3333* License: GPL-2.0 or GPL-3.0 or contact us for more
3434* Contact: Joel Parker Henderson (joel@sixarm.com )
@@ -459,7 +459,6 @@ select_character_class foo123goo456 alpha 3 1
459459=> g
460460` ` `
461461
462-
463462# ## reject_character_class
464463
465464Get a string' s characters that don' t match a class, with optional offset and length.
@@ -487,6 +486,248 @@ reject_character_class foo123goo456 alpha 3 1
487486=> 4
488487` ` `
489488
489+ # # Random character helpers
490+
491+ # ## random_char
492+
493+ Generate random characters
494+
495+ Syntax:
496+ ` ` ` sh
497+ random_char [characters [length]]
498+ ` ` `
499+
500+ Example:
501+ ` ` ` sh
502+ random_char ABCDEF 8
503+ => CBACBFDD
504+ ` ` `
505+
506+ Example hexadecimal digit uppercase:
507+ ` ` ` sh
508+ random_char 0-9A-F 8
509+ => FC56A95C
510+ ` ` `
511+
512+ Example character class for uppercase letters:
513+ ` ` ` sh
514+ random_char ' [:upper:]' 8
515+ => ZMGIQBJB
516+ ` ` `
517+
518+ POSiX character classes for ASCII characters:
519+ ` ` `
520+ Class Pattern Description
521+ ---------_ ------------- -----------
522+ [:upper:] [A-Z] uppercase letters
523+ [:lower:] [a-z] lowercase letters
524+ [:alpha:] [A-Za-z] uppercase letters and lowercase letters
525+ [:alnum:] [A-Za-z0-9] uppercase letters and lowercase letters and digits
526+ [:digit:] [0-9] digits
527+ [:xdigit:] [0-9A-Fa-f] hexadecimal digits
528+ [:punct:] punctuation (all graphic characters except letters and digits)
529+ [:blank:] [ \t ] space and TAB characters only
530+ [:space:] [ \t\n\r\f\v ] whitespace characters (space, tab, newline, return, feed, vtab)
531+ [:cntrl:] control characters
532+ [:graph:] [^ [:cntrl:]] graphic characters (all characters which have graphic representation)
533+ [:print:] [[:graph:] ] graphic characters and space
534+ ` ` `
535+
536+ # ## random_char_alnum
537+
538+ Get random characters using ` [:alnum:]` class.
539+
540+ Syntax:
541+ ` ` ` sh
542+ random_char_alnum [length]
543+ ` ` `
544+
545+ Example:
546+ ` ` ` sh
547+ random_char_alnum 8
548+ => 1Yp7M7wc
549+ ` ` `
550+
551+ # ## random_char_alpha
552+
553+ Get random characters using ` [:alpha:]` class.
554+
555+ Syntax:
556+ ` ` ` sh
557+ random_char_alnum [length]
558+ ` ` `
559+
560+ Example:
561+ ` ` ` sh
562+ random_char_alpha 8
563+ => dDSmQlYD
564+ ` ` `
565+
566+ # ## random_char_blank
567+
568+ Get random characters using ` [:blank:]` class.
569+
570+ Syntax:
571+ ` ` ` sh
572+ random_char_alnum [length]
573+ ` ` `
574+
575+ Example:
576+ ` ` ` sh
577+ random_char_blank 8
578+ => " \t \t \t"
579+ ` ` `
580+
581+ # ## random_char_cntrl
582+
583+ Get random characters using ` [:cntrl:]` class.
584+
585+ Syntax:
586+ ` ` ` sh
587+ random_char_alnum [length]
588+ ` ` `
589+
590+ Example:
591+ ` ` ` sh
592+ random_char_cntrl 8
593+ => " ^c^m^r^z^a^e^p^u"
594+ ` ` `
595+
596+ # ## random_char_digit
597+
598+ Get random characters using ` [:digit:]` class.
599+
600+ Syntax:
601+ ` ` ` sh
602+ random_char_alnum [length]
603+ ` ` `
604+
605+ Example:
606+ ` ` ` sh
607+ random_char_digit 8
608+ => 36415110
609+ ` ` `
610+
611+ # ## random_char_graph
612+
613+ Get random characters using ` [:graph:]` class.
614+
615+ Syntax:
616+ ` ` ` sh
617+ random_char_alnum [length]
618+ ` ` `
619+
620+ Example:
621+ ` ` ` sh
622+ random_char_graph 8
623+ => e' 2-3d+9
624+ ```
625+
626+ ### random_char_lower
627+
628+ Get random characters using `[:lower:]` class.
629+
630+ Syntax:
631+ ```sh
632+ random_char_alnum [length]
633+ ```
634+
635+ Example:
636+ ```sh
637+ random_char_lower 8
638+ => pgfqrefo
639+ ```
640+
641+ ### random_char_lower_digit
642+
643+ Get random characters using `[:lower:][:digit]` classes
644+
645+ Syntax:
646+ ```sh
647+ random_char_alnum [length]
648+ ```
649+
650+ Example:
651+ ```sh
652+ random_char_lower_digit 8
653+ => 69m7o83i
654+ ```
655+
656+ ### random_char_upper
657+
658+ Get random characters using `[:upper:]` class.
659+
660+ Syntax:
661+ ```sh
662+ random_char_alnum [length]
663+ ```
664+
665+ Example:
666+ ```sh
667+ random_char_upper 8
668+ => EGXUHNIM
669+ ```
670+
671+ ### random_char_upper_digit
672+
673+ Get random characters using `[:upper:][:digit:]` classes
674+
675+ Syntax:
676+ ```sh
677+ random_char_alnum [length]
678+ ```
679+
680+ Example:
681+ ```sh
682+ random_char_upper_digit 8
683+ => L2PT37H6
684+ ```
685+
686+ ### random_char_print
687+
688+ Get random characters using `[:print:]` class.
689+
690+ Syntax:
691+ ```sh
692+ random_char_alnum [length]
693+ ```
694+
695+ Example:
696+ ```sh
697+ random_char_print 8
698+ => ),zN87K;
699+ ```
700+
701+ ### random_char_space
702+
703+ Get random characters using `[:space:]` class.
704+
705+ Syntax:
706+ ```sh
707+ random_char_alnum [length]
708+ ```
709+
710+ Example:
711+ ```sh
712+ random_char_space 8
713+ => "\n \t\r \v \f"
714+ ```
715+
716+ ### random_char_xdigit
717+
718+ Get random characters using `[:xdigit:]` class.
719+
720+ Syntax:
721+ ```sh
722+ random_char_alnum [length]
723+ ```
724+
725+ Example:
726+ ```sh
727+ random_char_xdigit 8
728+ => eC3Ce9eD
729+ ```
730+
490731## Array helpers
491732
492733### array_n
0 commit comments