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

In Ubuntu, is it possible to cause one file to open whenever another file is opened (using a shell script, perhaps)?

For example, if I created a file called stuff.js, I'd want the file stuff2.js to be launched whenever I opened stuff.js from the desktop.

share|improve this question
You mean with one click you want open two files ? – Raja Oct 6 '12 at 6:37
Yes, that could easily be done using a shell script. But I want one file to automatically open whenever another file is opened - would it be better to simply use a shell script as a launcher for two separate files? – Anderson Green Oct 6 '12 at 6:39

you can create a little script:

touch myscript
chmod +x myscript

For Gnome

echo "gnome-open /path/to/file1" && gnome-open /path/to/file2" > myscript


echo "okular /path/to/file1" && okular /path/to/file2" > myscript 


echo "xdg-open /path/to/file1" && xdg-open /path/to/file2" > myscript

Note: use only one of the three methods.

Replace your file one's shortcut with this and just double click it, to open the two files simultaneously.

share|improve this answer

Open the second file from the first script. e.g. You have to call the stuff2.js from stuff.js. I think that is the simple way

share|improve this answer

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.