TONYHEAD
V2EX  ›  问与答

如何去掉代码中的“%0D”?

  •  
  •   TONYHEAD · Oct 1, 2012 · 6939 views
    This topic created in 5146 days ago, the information mentioned may be changed or developed.
    在一个.sh脚本中有一段代码:

    wget http://www.abc.com/transmission-2.04.tar.bz2

    在终端执行的过程中却会在尾部加上一个%0D,并提示文件找不到所以下载不了

    http://www.abc.com/transmission-2.04.tar.bz2%0D 404 Not Found

    而这个sh脚本我用Notepad++打开编辑过,代码中wget http://www.abc.com/transmission-2.04.tar.bz2的部分后面确实没有空格,请问要怎么修正呢?谢谢。
    5 replies  •  2020-06-19 16:47:58 +08:00
    shinwood
    shinwood
    Oct 1, 2012❤️1
    1
    试试 wget "http://....."
    funagi
    funagi
    Oct 1, 2012❤️1
    2
    在windows中,回车换行是\r\n (0x0D,0x0A)。
    在类unix中,是\n (0x0A)。
    在Notepad++中用正则替换一下应该就可以了。
    Js
    Js
    Oct 1, 2012❤️1
    3
    %0D应该是\r转义的, 试试用dos2unix或者mac2unix转一下
    cabbala
    cabbala
    Oct 2, 2012❤️1
    4
    @funagi notepad++有转换行尾符的功能,不需要正则
    holoword
    holoword
    Jun 19, 2020
    5
    使用 dos2unix 程序转换一下就 ok
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4972 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 06:43 · PVG 14:43 · LAX 22:43 · JFK 01:43
    ♥ Do have faith in what you're doing.