0

I have created a shell file which is executing another C files, if all the files are in the same directory then there is no problem but if my shell file is happened to be in a different directory than my C files, how would I get that shell file to run a C program present in a different directory?

1
  • Try /other/directory/C-program. Commented Feb 12, 2021 at 8:00

1 Answer 1

1

It is irrelevant for your question, where an executable is located (and in particular whether or not it is located in your working directory), and whether or not it has been compiled from C or something else. In general, if you want to execute a program X, you have three possibilities:

(1) Absolute path:

/my/path/to/X

(2) Relative path:

my/path/to/X

(this is equivalent to "$PWD/my/path/to/X")

(3) No path:

X

In the last case, the directories in the variable PATH are searched, until one is found which contains an executable named X.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.