【发布时间】:2013-12-19 00:43:55
【问题描述】:
首先,我想每隔 5 分钟定期删除 access_log 的内容 (/var/log/httpd/access_log)。请告诉我该怎么做??
其次,在 bash 脚本中,我定义了一个数组:
array=$(awk '{print $4}' /var/log/httpd/sample | uniq -c | cut -d[ -f1)
现在,我想知道如何使用带有此内容的 if 命令:
"if there is NOT any element in array, it means array=nothing, then echo "nothing in array".
这是一个关于数组的示例脚本:
# Tinh n2
arr=(${array[*]})
for (( i=(${#arr[@]} - 2),j=(${#arr[@]} - 1); i >= (${#arr[@]} - 2) , j > (${#arr[@]} - 2); i--,j-- )); do
b=$( expr ${arr[j]} - ${arr[i]} )
n2=$(abs $b)
done
echo "n2 = $n2"
请告诉我如何编码?
非常感谢。
【问题讨论】:
标签: arrays apache bash logging