Adicione a biblioteca no seu projeto
git submodule add https://github.com/eniltonangelim/dry-shell.git fslib
Configure a localização da biblioteca
export LIB_HOME="path/to/fslib"
source string/index.sh
First uppercase
~$ string.fupper foo bar baz
Foo Bar Baz
Uppercase
~$ string.upper foo bar baz
First lowercase
~$ string.flower FOO BAR BAZ
> fOO bAR bAZ
Lowercase
~$ string.lower FOO BAR BAZ
> foo bar baz
Other(s):
Name | Param #1 | Param #2 | Param #3 |
---|---|---|---|
string.flower | TEXT | ||
string.inverse | TEXT | ||
string.finverse | TEXT | ||
string.fupper | TEXT | ||
string.lower | TEXT | ||
string.upper | TEXT | ||
string.lstrip | TEXT | DEL STR | |
string.rstrip | TEXT | DEL STR | |
string.freplace | TEXT | OLD STR | NEW STR |
string.replace | TEXT | OLD STR | NEW STR |
source is/index.sh
~$ is.email? 113.213.13.1s3
> false
~$ is.email? dasdas@dsadas
> false
~$ is.email? [email protected]
> true
- IPv4
~$ is.ip.v4? 113.213.13.13
> true
~$ is.ip.v4? 113.213.13.1s3
> false
Other(s):
- number
- ip.v4
Unixtimestamp to datetime
~$ time.unix.to-datetime 1521451449
> Mon Mar 19 06:24:09 -03 2018
Datetime to unixtimestamp
~$ time.unix.from-datetime "Mon Mar 19 06:24:09 -03 2018"
> 1521451449
Relative position of two Datetime instances
- After
~$ time.is.date.after? 'Fri May 4 16:18:08' 'Fri May 4 16:18:08'
> false
~$ time.is.date.after? 'Fri May 4 17:18:08' 'Fri May 4 16:18:08'
> true
- Before
~$ time.is.date.before? 'Fri May 4 16:18:09' 'Fri May 4 16:18:08'
> false
~$ time.is.date.before? 'Fri May 4 16:18:04' 'Fri May 4 16:18:08'
> true
Datetime sequence Strategy (protocol)
20 minutes ago
time.range.strategy 20 1 'minutes' '%h %y %m:%d %H:%M:%S'
20 hours ago
time.range.strategy 20 1 'hours' '%h %y %m:%d %H:%M:%S'
20 days ago
time.range.strategy 20 1 'days' '%h %y %m:%d %H:%M:%S'
Datetime sequence In minutes
time.range.in-minutes '' '' '%Y-%m-%d %H:%M:%S'
time.range.in-minutes 23 '' '%Y-%m-%d %H:%M:%S'
time.range.in-minutes 23 3 '%Y-%m-%d %H:%M:%S'
Other's:
- time.range.in-seconds
- time.range.in-hours
- time.range.in-days
var nomes=( enilton patricia joao erica paulo junior julho )
- filter
~$ array.filter nomes e
> enilton
> erica
~$ array.filter nomes j
> joao
> junior
> julho
~$ array.filter nomes ju
> junior
> julho
- contains
~$ array.contains nomes enilton
> true
$ array.contains nomes amy
> false
- select
~$ menu.select "Choose the IP: " "`network.ip.v4.list`"
1) 10.254.252.56
2) 127.0.0.1
3) 172.17.0.1
4) 192.168.124.101
5) Q to quit
Choose the IP: 2
> 127.0.0.1
- Search expression in file
~$ time async.search.in /var/log/syslog "firefox" && async.search.in /var/log/syslog cron
real 0m0.004s
user 0m0.003s
sys 0m0.001s
May 9 00:08:06 note01-dev anacron[8593]: Job `cron.daily' terminated
~/workspace/fun-shell$ May 9 00:12:56 f13note01-dev anacron[8593]: Job `cron.weekly' started
May 9 00:12:56 note01-dev anacron[13060]: Updated timestamp for job `cron.weekly' to 2018-05-09
...
May 9 08:02:56 note01-dev systemd[1]: Started Run anacron jobs.
May 9 09:35:04 note01-dev firefox[7482]: ../../../../gobject/gsignal.c:3492: signal name 'selection_changed' is invalid for instance '0x7fe224c6d3d0' of type 'MaiAtkType319'
May 9 08:02:56 note01-dev anacron[17845]: Anacron 2.3 started on 2018-05-09
May 9 09:36:00 note01-dev firefox[7482]: message repeated 34 times: [ ../../../../gobject/gsignal.c:3492: signal name 'selection_changed' is invalid for instance '0x7fe224c6d3d0' of type 'MaiAtkType319']
- Run any async-command
~$ testeA=("ckr domain foobar.com.br [email protected] adminLoginAs" "ckr domain foobar.com.br [email protected] adminLoginAs" "ckr domain foobar.com.br [email protected] adminLoginAs" "ckr domain foobar.com.br [email protected] adminLoginAs")
~$ async.run zmprov testeA
~$ prov> ckr domain foobar.com.br [email protected] adminLoginAs
ALLOWED
prov> prov> ckr domain foobar.com.br [email protected] adminLoginAs
ALLOWED
prov> prov> ckr domain foobar.com.br [email protected] adminLoginAs
ALLOWED
prov> prov> ckr domain foobar.com.br [email protected] adminLoginAs
ALLOWED
prov>
source screen/index.sh
~$ screen.box.dialog 1 1 'Hello World!\n\Willkommen!'
┌──────────────┐
│ Hello World! │
│ Willkommen! │
└──────────────┘
source math/index.sh
- Test inodes:
has.file.same.inode? /etc/hosts /etc/hosts.deny
source math/index.sh
- add
math.add 12 31
- div
math.div 10 2
- mod
math.mod 10 2
- mul
math.mul 10 3
- pow
math.pow
- sub
math.sub 5 3