I have youtube-dl and xclip installed.

Is there a way I could write a script that can run commands from both?

For example: youtube-dl -l --extract-audio (url) but instead of pasting a url could I have xclip paste what's in my clipboard with the command: xclip -o

I am a complete noob when it comes to scripting and not even sure what I should use to write the script, as far as I can tell I should use Bash.

  • 1
    Do I understand you correctly, you want to browse Youtube and copy a link of a video, then have a script that calls youtube-dl & xclip which automatically gives it the video link, In other words you won't have to open up your terminal and run the commands manually, whatever you copy to your clipboard will essentially be downloaded automatically in the background? – kingmilo Feb 21 '12 at 7:40
  • That would also work if you know of a way to do that. – MrHotsauce Feb 21 '12 at 18:14

You almost had the code:

youtube-dl -l --extract-audio "$(xclip -o)"

$(command) executes command and $(...) is then substituted for the standard output of command. The quoting is necessary to prevent output containing whitespace from breaking the command.

  • oh wow that did it. Thanks i feel pretty dumb because that was so easy xD – MrHotsauce Feb 21 '12 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.