免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1568 | 回复: 2
打印 上一主题 下一主题

我想备份今天生成的文件,用set失败。求助ing [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-01-06 11:37 |只看该作者 |倒序浏览
-rw-r----- 1 oracle dba  556 Dec 30 15:58 test.log.bak
-rw-r----- 1 oracle dba  556 Dec 30 16:08 test.log
-rw-r----- 1 oracle dba 1427 Dec 30 18:25 rman_bak.sh
-rw-r--r-- 1 oracle dba  695 Dec 31 00:02 expdb.log
-rw-r----- 1 oracle dba  948 Dec 31 17:57 test.sh
-rw-r----- 1 oracle dba  152 Dec 31 18:02 test1.sh
-rw-r----- 1 oracle dba    0 Jan  6 11:37 111.txt
-rw-r----- 1 oracle dba    0 Jan  6 11:37 222.txt

我想实现一个功能,备份今天生成的文件,用下面的脚本没有办法获取到文件

脚本如下


set $(date)

V_Month=$2
V_Day=$3
V_MoDy=$2" "$3
ls -lrt |grep ^-|grep "$V_MoDy"|awk '{print $9}'|xargs tar -cf backup_`date +%Y%m%d`.tar


ls -lrt |grep "$V_MoDy" 没有结果。

date的显示格式。

Fri Jan  6 11:42:56 CST 2012



还有别的办法吗?求助。

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
2 [报告]
发表于 2012-01-06 12:02 |只看该作者
回复 1# xcsars


    用 find 吧,比你那个方便多了。

论坛徽章:
0
3 [报告]
发表于 2012-01-06 14:23 |只看该作者
find - search for files in a directory hierarchy

SYNOPSIS
       find [-H] [-L] [-P] [path...] [expression]
for example:
       -anewer file
              File  was last accessed more recently than file was modified.  If file is a symbolic link and the -H option or the -L option is
              in effect, the access time of the file it points to is always used.

       -atime n
              File was last accessed n*24 hours ago.  When find figures out how many 24-hour periods ago the  file  was  last  accessed,  any
              fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.

       -cmin n
              File status was last changed n minutes ago.

       -cnewer file
              File  status  was  last changed more recently than file was modified.  If file is a symbolic link and the -H option or the -L
              option is in effect, the status-change time of the file it points to is always used.

       -ctime n
              File status was last changed n*24 hours ago.  See the comments for -atime to understand how rounding affects the  interpreta-
              tion of file status change times.


例子:
              find . -mtime 1  -exec ls -l '{}' \;           #我这样好像只是把今天内的所有文件都列出来了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP