Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

2 Answers 2

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

For KDE

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

Alternative

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

 
discard

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.