JamesHopbourn
V2EX  ›  Bash

Shell 中冒号变成了斜线

  •  
  •   JamesHopbourn · Dec 24, 2019 · 7278 views
    This topic created in 2511 days ago, the information mentioned may be changed or developed.

    james$ touch test
    james$ cp test "test $(date "+%Y:%m:%d %H:%M")"
    james$ ls
    test test 2019:12:24 22:13

    本想用 cp 做备份,格式化输出:年-月-日 时:分。但是在 $(date) 中的 : 会变成 / 。 在 ls 中查看是 test 2019:12:24 22:13,但是实际桌面看到是:test 2019/12/24 22/13,我的预期结果是:test 2019/12/24 22:13

    请问是否有解决办法?我试过 \ 但是并没没用

    屏幕快照 2019-12-24 下午 10.18.06.png

    JamesHopbourn
    JamesHopbourn
    OP
    Dec 24, 2019
    2
    @ynyounuo 这个想到过,但是试过了,会报错
    james$ cp test "test $(date "+%Y:%m:%d %H'/'%M")"
    cp: test 2019:12:24 22'/'32: No such file or directory

    james$ cp test "test $(date "+%Y:%m:%d %H/%M")"
    cp: test 2019:12:24 22/33: No such file or directory
    ynyounuo
    ynyounuo
    Dec 25, 2019 via iPhone❤️1
    3
    @JamesHopbourn 额…… 你真的点开看了吗
    JamesHopbourn
    JamesHopbourn
    OP
    Dec 25, 2019
    4
    @ynyounuo 懂了 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3937 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 03:43 · PVG 11:43 · LAX 19:43 · JFK 22:43
    ♥ Do have faith in what you're doing.