I am storing a url inside a variable in bash. It has nothing to do with real file paths but it keeps giving me the error File name too long.
How do I tell bash to ignore looking for filenames and just store the long url string into the variable?
I am not using a file name. Can someone please explain and guide me on why I am getting that error that doesn't seem relevant?
#!/bin/bash
video=""
$video=$(youtube-dl -g -f bestvideo https://youtubeurl)
echo $video
$ Bash script.sh
error: File name too long
Edit : Apologies,I used $( ) before the command. I typed it wrongly here on the stackexchange editor.Corrected it above.Tried using echo "$video" . I still get the same error. I am using ubuntu on Windows Subsystem for Linux
bash
with a capitalB
which lead me to believe that you were not in fact copying the actual command. Also, I can't provokebash
noryoutube-dl
to produce that specific error ("No such file or directory" is very different from "Filename too long"). That's why I asked. I was just trying to reproduce your error and I couldn't. When I can't reproduce an error, I have to ask what you're doing, as I can't be sure you are actually showing everything exactly the way it happens. – Kusalananda Jun 08 '19 at 09:01youtube-dl
to your variable with a proper assignment (not$video=...
) and then added the$
tovideo
somehow and tried it again. This would indeed have given that error. But again, this is not in the code that you show. – Kusalananda Jun 08 '19 at 09:06