I'm doing a simple iteration over a remote text file content, but get stuck in splitting file names as they have spaces inside.
#!/bin/bash
for u in $(curl http://XXXXXX.com/urls.txt)
do
wget "${u%|*}" -O "${u#*|}" -P ./Directory/
done
Text file contains below strings per line:
https://OOOOOOOO.com?url1|My file with spaces in name.mp4
https://OOOOOOOO.com?url2|How to escape spaces?.mp4
https://OOOOOOOO.com?url3|Mixed up.mp4
https://OOOOOOOO.com?url4|Asking StackOverFlow!.mp4
I looked at many similar issues already, made many approaches but all results the same thing.
When I do a echo ${u#*|}
alone, I have the output:
My
file
with
spaces
in
name.mp4
Mixed
up.mp4
.
.
.
What's wrong?