Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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
up vote 3 down vote accepted

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.

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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