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 am trying to create a script to run vlc to play (or queue if a playlist is already present) some videos.

so far in my ~/bin/ folder I have created a file ``myvlc'' with the following command:

#!/usr/bin/env bash
vlc --http-port 54444 %U

This works as a command if I set it as launcher command in an icon, but it doesnt work if from the command line I type: myvlc ~/Videos/Some\ Folder/video.avi

How can I modify this bash script and make it work?

share|improve this question
up vote 3 down vote accepted

Suggestion: use Bash aliases

Aliases allow you to append more arguments and 'overrule' current commands too. For example, this alias:

alias hvlc='vlc --http-port 54444'

will make

hvlc -v /path/to/my/movie.mkv

to become

vlc --http-port 54444 -v /path/to/my/movie.mkv

If you like the alias, install it permanently:

echo "alias hvlc='vlc --http-port 54444'" >> ~/.bash_aliases

The default ~/.bashrc file installed for users in Ubuntu will source the ~/.bash_aliases file by default.

More about aliases in an earlier answer of me.

About your script

It's not passing the arguments to the vlc command as given to the "parent" Bash script. To fix this, make the line

vlc --http-port 54444 $@

The $@ is the Bash magic for "all arguments". The %U is only used in .desktop files in GUIs and is a magic string to place the URL to be opened.

share|improve this answer
thanks your answer has been really helpful! Since you were kind enough to send me a link for aliases, do you have any clear tutorial for bash scripting as well? – lucacerone Jan 30 '13 at 19:05
ok the script works fine now thanks! Now how can I make it the default to be used when opening a video file? – lucacerone Jan 30 '13 at 19: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.