Move to Chezmoi
This commit is contained in:
parent
f216c4ff2c
commit
e3498e73b5
59 changed files with 499 additions and 2240 deletions
chezmoi/dot_zshrc.d
22
chezmoi/dot_zshrc.d/executable_ip-int-convert.sh
Normal file
22
chezmoi/dot_zshrc.d/executable_ip-int-convert.sh
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
# convert integer to IP
|
||||
int2ip () {
|
||||
local ip dec=("$@")
|
||||
for e in {3..0}
|
||||
do
|
||||
((octet = dec / (256 ** e) ))
|
||||
((dec -= octet * 256 ** e))
|
||||
ip+=$delim$octet
|
||||
delim=.
|
||||
done
|
||||
printf '%s\n' "$ip"
|
||||
unset delim
|
||||
}
|
||||
|
||||
# convert IP to integer
|
||||
ip2int () {
|
||||
local a b c d ip
|
||||
ip=("$@")
|
||||
IFS=. read -r a b c d <<< "${ip[*]}"
|
||||
printf '%d\n' "$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue