2016-05-04 20:12:28 +02:00
|
|
|
# js function syntax for bash
|
|
|
|
|
|
|
|
function trimend {
|
|
|
|
LENGTH=${#1}
|
|
|
|
AMT=$2
|
|
|
|
TAKE=$((LENGTH-AMT))
|
|
|
|
echo $1 | cut "-c-$TAKE"
|
|
|
|
}
|
|
|
|
|
|
|
|
function trimfront {
|
|
|
|
TMP0=$(echo $1 | rev)
|
|
|
|
TMP1=$(trimend $TMP0 $2 | rev)
|
|
|
|
echo $TMP1
|
|
|
|
}
|
|
|
|
|
|
|
|
function length {
|
|
|
|
echo ${#1}
|
|
|
|
}
|
|
|
|
|
|
|
|
function slice {
|
2016-06-29 23:59:44 +02:00
|
|
|
start="$1"
|
|
|
|
end="$2"
|
|
|
|
string="$3"
|
|
|
|
echo "${string:${start}:${end}}"
|
2016-05-04 20:12:28 +02:00
|
|
|
}
|
2016-06-21 15:59:34 +02:00
|
|
|
|
|
|
|
function setInterval {
|
|
|
|
eval "while true; do $1; sleep $2; done"
|
|
|
|
}
|