Edit PATH by adding current directory. To compile a *.c file without by typing a filename without "./"

StackOverflow https://stackoverflow.com/questions/20358587

  •  28-08-2022
  •  | 
  •  

I added this line:

PATH=.:$PATH

to my .bash_profile.

Now I have to make main.c compile when I type zz (under the same directory in ~/user/filename)

  1. What do I have to write in the zz shell script?
  2. Did I add the current directory correctly?
有帮助吗?

解决方案

PATH determines where executables are searched; it has no influence on where source files are searched. Source files without a directory component are searched in the current directory anyway. What you have to write to compile main.c depends on the compiler used, which you didn't specify, but it's usually like cc main.c. Also consider using make rather than writing a shell script.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top