-
Notifications
You must be signed in to change notification settings - Fork 0
/
strings
executable file
·67 lines (57 loc) · 1.96 KB
/
strings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
#
# ############################################################################
# Project: xSHELL (none)
# File...: strings
# Created: Friday, 2021/05/21 - 21:09:41
# Author.: Fabiano Matos, fgm ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 16:45:34
# Modified By..: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.1.4.92
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
_xLIB_STRINGS_=true
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# import libs/functions
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# split a string by a ginver char
# @param $1 - string to be splited
# @param $2 - split in this char (it will be removed)
# @return $array - string splited
strSplit(){
local array=( $(echo "$1" | tr -s "$2" ' ') )
echo "${array[@]}"
}
# convert string to a array with each char
strChars(){
local array=( $(echo "$1" | fold -w1 | tr -s '\n' ' ') )
echo "${array[@]}"
}
# get SIZE of a str
strLen(){ echo "${#1}"; }
alias strSize=strLen
# echo $1 | wc -m
# reverse a str
strReverse(){ echo "$1" | rev; }
# change case of a string
upcase(){ echo "$1" | tr a-z A-Z ; }
lowcase(){ echo "$1" | tr A-Z a-z ; }
# check if a string contains another string
# @param $1: string alvo da busca
# @param $2: texto a ser pesquisado na string
strInclude(){
local string=$1; reqsubstr=$2;
if [ -z "${string##*$reqsubstr*}" ]; then
echo "true"
# return 0
else
echo "false"
# return 1
fi
}