在linux中将日期附加到文件名 [英] Append date to filename in linux

查看:30
本文介绍了在linux中将日期附加到文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文件名(somefile.txt")旁边添加日期.例如:somefile_25-11-2009.txt 或 somefile_25Nov2009.txt 或任何类似的内容

I want add the date next to a filename ("somefile.txt"). For example: somefile_25-11-2009.txt or somefile_25Nov2009.txt or anything to that effect

也许脚本会在终端窗口中执行或执行某些命令.我使用的是 Linux(Ubuntu).

Maybe a script will do or some command in the terminal window. I'm using Linux(Ubuntu).

提前致谢.

哦,我差点忘了补充,每次您想将文件保存到特定文件夹但仍保留以前的文件时,脚本或命令都应将文件名更新为新日期.所以最终文件夹中会有这样的文件: filename_18Oct2009.txt , filename_9Nov2009.txt , filename_23Nov2009.txt

oh i almost forgot to add that the script or command should update the filename to a new date everytime you want to save the file into a specific folder but still keeping the previous files. So there would be files like this in the folder eventually: filename_18Oct2009.txt , filename_9Nov2009.txt , filename_23Nov2009.txt

推荐答案

您可以使用反引号.

$ echo myfilename-"`date +"%d-%m-%Y"`"

产量:

myfilename-25-11-2009

这篇关于在linux中将日期附加到文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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