使用时间戳重命名UNIX中的文件命令

编程入门 行业动态 更新时间:2024-10-28 10:22:21
本文介绍了使用时间戳重命名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中的文件命令

本文发布于:2023-10-28 08:55:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536154.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重命名   命令   文件   时间   UNIX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!