dl528888
作者dl528888·2015-06-05 15:12
系统运维工程师·游戏公司

关于时间的shell问题,需要调用shell为具有年月日的,比如20110919

字数 387阅读 1160评论 0赞 0

在shell里想要显示时间,必须位day=”$(date +%Y%m%d)”,这样才可以,比如我的log文件名为access_log.20110919,想要用shell脚本来查看这个文件是否存在,就得用一下的shell来查询:

#!/bin/bash

day="$(date +%Y%m%d)"

size='/tmp/logs/access_log.'

if [ -f $size$day ]

then

echo "exist"

else

echo "no exist"

fi

测试结果为:

[root@244835 tmp]# ./3.sh

Exist

Log存在的位置如下

[root@244835 logs]# ll | grep access_log.20110919

-rw-r--r-- 1 root root 1146696 Sep 19 21:17 access_log.20110919

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广