#!/bin/sh
db2 list active databases | grep “Database name” |awk -F ‘=’ ‘{print $2}’ > /tmp/active.out
db2 list db directory | grep “Database name” |awk -F ‘=’ '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲' > /tmp/alldb.…(cat /tmp/active.out)
DBNAMELIST=
(
c
a
t
/
t
m
p
/
a
l
l
d
b
.
o
u
t
)
i
f
[
−
n
"
(cat /tmp/alldb.out) if [ -n "
(cat/tmp/alldb.out)if[−n"{DBNAME}" ]; then
echo “actived db”
echo ${DBNAME}
cat /tmp/alldb.out | while read ONEDBNAME
do
cat /tmp/active.out | grep "${ONEDBNAME}" > /tmp/result.out
result=$(cat /tmp/result.out) e
if [ -z "${result}" ]; then # -z 变量为空
echo "active follow db : ${ONEDBNAME}"
db2 activate db ${ONEDBNAME}
else
echo "${ONEDBNAME} have been actived"
fi
done
else
cat /tmp/alldb.out | while read ACTONEDB
do
db2 activate db ${ACTONEDB}
done
fi