【发布时间】:2023-04-11 03:50:01
【问题描述】:
可能重复:
How can I change the format of a date from the command line?
我正在运行一个下载和 XML 文件的夜间 cron 作业。 XML 文件的日期格式如下:
<date>2011-09-30</date>
我想设置第二个 cron 作业,将每个日期更改为如下格式:
<date>September 30</date>
然后保存文件。
有没有使用 shell 脚本的好方法?
【问题讨论】:
-
我确信这可以通过调用 sed 来完成......但我个人我会使用像 nokogiri.org 这样的 XML 工具来做这样的事情。只是个人喜好,因为如果格式发生变化等,使用字符串替换来破解 XML 会导致问题。
-
@Kansha,看我的帖子,这就是我在 shell 中展示纯 Xpath 解决方案的原因。