Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
26
Task/Introspection/UNIX-Shell/introspection-2.sh
Normal file
26
Task/Introspection/UNIX-Shell/introspection-2.sh
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
if [[ $BASH_VERSION < "4.2" ]]; then
|
||||
echo "version is too old"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ ! -v bloop ]]; then
|
||||
echo "no bloop variable"
|
||||
elif [[ $(type -t abs 2>/dev/null) != function ]]; then
|
||||
echo "abs is not a shell function"
|
||||
else
|
||||
echo $(abs $bloop)
|
||||
fi
|
||||
|
||||
# need to populate the variables and use them within the same subshell in a pipeline.
|
||||
set | {
|
||||
shopt -s extglob
|
||||
int_vars=()
|
||||
while IFS='=' read -r var value; do
|
||||
if [[ $value == +([[:digit:]]) ]]; then
|
||||
int_vars+=($var)
|
||||
(( sum += value ))
|
||||
fi
|
||||
done
|
||||
echo "${int_vars[*]}"
|
||||
echo $sum
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue