【问题标题】:converting epoch time from decimal to hex in Makefile在Makefile中将纪元时间从十进制转换为十六进制
【发布时间】:2014-05-21 16:00:10
【问题描述】:

我想将二进制的纪元时间转换为十六进制。我可以通过以下命令在命令行中执行此操作

# epoxy time in decimal
me@bof:/auto/homes$ date +%s
1400687648

# epoxy time in hex
me@bof:/auto/homes$ printf "%x\n" $(date +%s)
537ccc3b

现在我想在 Makefiles 中执行上述操作,我正在尝试使用 $(shell) 命令,但我遗漏了一些东西。

identifier:
        $(shell date +%s) 
        $(shell printf "%x\n" $(date +%s))

有人可以帮我解决上述问题吗? 谢谢

【问题讨论】:

  • 为什么标记为 C?

标签: c makefile type-conversion


【解决方案1】:

你忘了把shell 打给date

identifier:
    printf "%x\n" $(shell date +%s)

【讨论】:

    【解决方案2】:

    您为什么要在配方中使用$(shell ...) 函数?每个配方已经在 shell 中运行...为什么要执行两次?我一直看到这个,我不知道它来自哪里。

    试试:

    identifier:
            date +%s
            printf "%x\n" $$(date +%s)
    

    【讨论】:

    • 谢谢你这是一个有效的观点,我接受它,我想 Pavel 用你的观点更新了他的答案。再次感谢
    猜你喜欢
    • 2015-03-12
    • 1970-01-01
    • 2014-12-31
    • 2011-07-28
    • 1970-01-01
    • 2018-09-04
    • 2017-07-31
    相关资源
    最近更新 更多