bash检查核心存在并且是最新的
我正在寻找一种更简单的方法:bash检查核心存在并且是最新的,bash,find,Bash,Find,我正在寻找一种更简单的方法: #!/usr/bin/bash FILE=core DAYS=1 cd /programdir if [ -f ${FILE} ]; then agetest=$(find . -name "${FILE}" -type f -mtime +${DAYS} -print | wc -c) if [[ agetest -eq 0 ]] ; then echo "$FILE exists and is not older than ${DA
#!/usr/bin/bash
FILE=core
DAYS=1
cd /programdir
if [ -f ${FILE} ]; then
agetest=$(find . -name "${FILE}" -type f -mtime +${DAYS} -print | wc -c)
if [[ agetest -eq 0 ]] ; then
echo "$FILE exists and is not older than ${DAYS} days."
fi
fi
如果脚本找到了一个核心文件,并且该核心文件是最新的(在1天内),我想处理它(使用dbx命令)。因此,我将在echo语句所在的位置运行dbx命令。似乎应该有一种更优雅的方法来使用1if语句实现这一点,但我想不出该如何实现。有什么想法吗
我知道用tmpwatch或find/rm清理旧的核心文件会更容易,但我不允许这样做。谢谢。我意识到我在哪里-mtime+那需要-mtime-谢谢。我意识到我在哪里有-mtime+那应该是-mtime-
#!/usr/bin/bash
FILE=core
DAYS=1
if [ `find /programdir -name "${FILE}" -type f -mtime +${DAYS}` ]; then
echo "$FILE exists and is not older than ${DAYS} days."
fi