I know this is a very simple question, and that many similar (but more complicated!) questions have been asked- So i wanted to ask this in a very plane manner. Sorry if this voids the rules of conduct on this website! I'm very new to using unix.

I have a program that converts a ".evt" file to an .rq1, which is used for data analysis. The command to do so is simple, for example: Convert data.evt (this outputs data.rq1).

This program, let's say, is located in directory /A and I have a data file that I want to convert in directory /B. How would I go about executing this program without moving the convert program to directory B?

  • any problem with changing to directory /B and executing /A/program ? Nov 26, 2011 at 22:45

5 Answers 5


It is very simple:

./A/Convert B/some_file  

It means go to the directory A and run the program with parameter that you will give.

  • Wow thanks so much for the quick response that really is quite simple- everything else I've tried seemed to be much more complicated (and more "robust") than what I needed.
    – user1067358
    Nov 26, 2011 at 22:52
  • Note that the "dot" means current directory, so the above won't work unless A is in whatever directory you are in.
    – LawrenceC
    Sep 11, 2014 at 12:08

In UNIX File System, all your inbuilt commands are binaries (programs) written to perform certain tasks. ls command does the listing of directories, mv command moves or renames files etc.

All these binaries are stored in your /usr/bin directory. And the path to that directory is stored in your PATH environment variable.

If you have many scripts that do certain tasks, I would recommend them to move in one folder. say for example, /yourname/scripts and then set this path in your PATH variable.

PATH variable can be set in your .bashrc or .bash_profile file which gets loaded up whenever you fire a terminal session. You can view your PATH variable settings by doing an echo on it.

[jaypal~]$ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin:/Developer/usr/bin:/usr/local/ActivePerl-5.12/bin:/Library/Ruby/Site/1.8/rubygems:/Library/Ruby/Gems/1.8/gems/wkpdf-0.5.3-universal-darwin/bin:/Library/Ruby/Gems/1.8/gems/wkpdf-0.5.3-universal-darwin/lib

In your .profile file, simply add :/yourname/scripts folder and do . .profile on your shell prompt. This will force your current session to load your profile file without having to quit and log in again.

Once the .profile file has been loaded, you can run your script from anywhere by simply typing scriptname options or other arguments as needed.

This tutorial will be helpful to you.

  • no one should ever add a directory to PATH just to be able to run a single program from it, ln -s is a way better solution Nov 26, 2011 at 22:57
  • What could be the potential issue? It's not just for running one program. All user created scripts can be placed in one such folder and can be called in from any location. Nov 26, 2011 at 23:08
  • If it's not just for running a single program then you place it in ~/bin -- it is automatically added to the PATH by bash. This is a standard approach unlike your /yourname/scripts Nov 27, 2011 at 6:35
  • Yea, you can do that too. I feel more comfortable having a separate folder containing scripts I write, keeping them separate from the binaries that comes with my distribution. I still don't see a potential pitfall in adding a folder to my PATH variable. Nov 27, 2011 at 6:46
  • nothing comes with your distribution in ~/bin, it is solely for your own scripts Nov 27, 2011 at 6:50

One convention used by most experienced unix users (not supplied by the system) is to create a local bin directory--inside the user's home directory--as a repository for user-created scripts and programs. (taken from here)

Place you program in ~/bin directory (which is a short for /home/yourname/bin) and you will be able to run your program from any location, because when ~/bin exists bash adds it to the PATH by default (at least on Ubuntu). You will need to create this directory if it doesn't exist.

If you feel like becoming a more advanced linux user - use ln -s to link your program from its location to ~/bin

/path/to/A/Convert /path/to/B/data.evt

...and your output file should end up in your current directory (assuming you have write access).

Additionally, what flavor of Unix are you using?


Run it just like so:

/A/Convert /B/data.evt

Remember not to lead /A with a . as , means current directory. Unless of course the path you're providing is relative to the current directory.

Your Answer

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