Skip to content

Latest commit

 

History

History
139 lines (106 loc) · 2.33 KB

README.md

File metadata and controls

139 lines (106 loc) · 2.33 KB

bash-utils

$ git clone https://github.com/zx80live/bash-utils
$ cd ./bash-utils

util_files

# import util_files
$ source util_files
# create nested dirs if it isn't exist
$ touch_dir '/a/b/c/d/e/f'
# create file if it isn't exist including all nested dirs in its path
$ touch_file '/a/b/c/d/e/f/hello.txt'

util_logs

# import util_logs
$ source util_logs
$ log_info 'some log info string'

image-20201109210636121

$ log_err 'some err string'

image-20201109210744075

$ log_debug 'some debug string'
# there is nothing in output, because log_level variable is LOG_LEVEL_INFO by default

$ export log_level=$LOG_LEVEL_DEBUG
$ log_debug 'some debug string'

image-20201109211020220

util_text

# import util_text
$ source util_text
# list of available formats
$ strformats

image-20201109202710823

$ strformat "Hello, World" CYAN BOLD ITALIC

image-20201109203059108

$ strlen "Hello, World"
12
$ substring "0123456789ABCDEFGH" 10 3
ABC
$ strdrop_right "0123456789ABCDEFGH" 8
0123456789
$ strdrop_left "0123456789ABCDEFGH" 10
ABCDEFGH
$ strfill_right "ABC" '.' 10
ABC..........
$ strfill_left "ABC" '.' 10
..........ABC
$ strdecorate "some text" '~~' '~~'
~~some text~~
# get matched regex groups
$ strregex "Some string with some 123 number and SPECIAL word." '.*([0-9]{3}).*(SPECIAL).*'
Some string with some 123 number and SPECIAL word.
123
SPECIAL
$ strunwrap "~~some text~~" '~~' '~~'
some text
$ strtake_left "0123456789ABCDEFGH" 5
01234
$ strtake_right "0123456789ABCDEFGH" 5
DEFGH
$ strsplit 'A.B.C.D' '.'
A
B
C
D