---
# System prepended metadata

title: Untitled

---

Hey Daniel, I have a text file (`urls.txt`) with a list of 60+ pipe-separated lines like so:

    name1|url1
    name2|url2
    name3|url3

I would like to run the following command in Terminal on all the lines:
`youtube-dl -o name1 url1`

So I wrote a Ruby program `grab_urls.rb`:

    #!/usr/bin/ruby
    filename = './urls.txt'
    File.foreach(filename) do |line|
       pair = line.split("|")
       youtube-dl -o "#{pair[0].mp4}" "#{pair[1]}"
    end

However, I keep getting this error:

    grab_urls.rb:7: syntax error, unexpected unary-, expecting 'do' or '{' or '('
    youtube-dl -o "#{pair[0].mp4}" "#{pair[1]...

I think it is complaining about the dash (`-`) in the flag `-o` but I am not sure how to resolve that in the ruby file. 🤷🏽‍♀️