使用时间戳重命名UNIX中的文件命令 [英] Rename file command in unix with timestamp

查看:174
本文介绍了使用时间戳重命名UNIX中的文件命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在使用腻子,并尝试使用当前时间戳重命名文件名... 我已经使用以下命令重命名文件并根据日期 mv abc.log $(date +%F)prod.txt

Hello i'm using putty and trying to rename a file name with current time stamp ... I've used following Command to rename the files and according to date mv abc.log $(date +%F)prod.txt

以上命令已重命名但无法随时间重命名,其输出为:2014-05-12prodabc.log

above command renames but not able to rename with time, It giving Output as : 2014-05-12prodabc.log

以及以下命令 abc.log $(date +%y)$(date +%m)$(date +%d)abcprod.log

And following command abc.log $(date +%y)$(date +%m)$(date +%d)abcprod.log

将输出显示为:140512abc.log

giving output as : 140512abc.log

实际上我的要求如下.

rename abc.log to abc-current timestamp.log 
e.g abc.log  become  abc-12-05-2014-17:31.log
then create new file abc.log

请帮助,谢谢大家.

推荐答案

您可以使用

mv test.dat test_$(date +%d-%m-%Y).dat

如果您想知道如何控制输出,请查看手册页的日期.

If you want to know how you can control your output have a look at the date Manpages..

man date 

这篇关于使用时间戳重命名UNIX中的文件命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆