wget Script : %0D at the end of filename

2

I have a bash script who loop on the wget command. But I don't know why I have a %0D at the end of all of the filenames except the first.

for var in "${array[@]}"
do
    wget -P output_folder "${var}"
done

Why I have this ? How to resolve this ?

Kaayo25

Posted 2017-02-23T11:26:09.753

Reputation: 73

What URLs are you using? – NonlinearFruit – 2017-02-23T13:17:21.083

If the URL Has it in then it should be there (though %0D might be a bit strange or unusual in a URL. Sometimes URLs write funny characters in with a percentage followed by the character's utf-16 code. So sometimes a "literal" ampersand character might be or would be, written in with its utf-16 code. – barlop – 2017-02-23T13:39:26.687

I am using server's url with a lot of characters (tokens etc...). I don't saw for the moment any modulo in the url. Meanwhile, I stock the url in a file and I launch the command wget -i. – Kaayo25 – 2017-02-23T14:03:17.347

1@Kaayo25 the 0D character is often found in windows text files as it's one of the new line characters. So try converting the file from windows line separators to unix line endings, then feed it to wget. There are other things you could try too, like having the file contain just the problem URL, then do you can xxd filename and look at the hex of the file, and cat the file and look at the file(that way with xxd, will show hex and corresponding text). And you'll just understand better what is going on. Does it happen with every URL in the file or just one? – barlop – 2017-02-23T14:22:47.270

also i've heard that the old mac os used to use 0d as the new line character/ – barlop – 2017-02-23T14:26:13.467

notepad++ has an option to convert from windows line separators to unix line endings. And if you are using a hex editor or xxd then you can see what it has done. You may also be able to find commands like dos2unix or unix2dos that let you convert between \r\n and \n i.e. between windows line separators and unix line endings. – barlop – 2017-02-23T14:26:56.020

It's happen with all url. I am note on notepad++, I code the script with nano on debian 8. I will test with xxd – Kaayo25 – 2017-02-23T15:07:42.673

No answers