If you want to run shell script on Linux, why would you start with a point and slash like./somescript.sh? DOS does not need something like that.

Dos?Not exactly the culmination of computer science.

A program under Linux has the form of a file name and a command usually starts with that name, followed by the other ‘ arguments ‘, apart from special characters that are manipulated and removed by the shell.

A program can therefore be called ‘ somescript ‘ or ‘ somescript.sh ‘.The shell then searches for a file with that name and finds it in a series of directories that are in the $PATH variable (the search path). The difference me DOS is that in the latter case the current directory was automatically considered part of the search path. Other arguments that are considered file names are just searched in the current directory.

The reason is that if a student writes a program called ‘ ls ‘ and the system administrator is viewing the student’s directory and typing ‘ ls ‘, that would otherwise run the student’s program instead of the normal ‘ ls ‘ command.

In all cases, the file is found when you add the name of the directory, without the need for a search path.

Linux doesn’t need it either.

But then the current directory should be in your $PATH.For example, your $PATH usually have/usr/bin and/usr/local/bin and other paths where ‘ all scripts are ‘. You can edit your path yourself as a * nix user.

So you can add ‘. ‘ to your $PATH.But that is usually not the same:

Why is. Not in the path by default?

That is just the PATH environment variable in Linux (or UNIX).
PATH enumerates all folders-separated by “:”-in the order in which the shell should search for executables (both scripts and binaries).

Example from OSX:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

If the path says “current directory”, represented by “.” (= a point), the command interpreter also looks in the folder where you are located.You can just adjust this in your profile.

If you put the relative path “./” before your script then Linux does not need to search through PATH, because you have indicated that the script is in your working directory.The same of course also if you use the full path (e.g:/home/usr/donaldtrump/thebestscriptintheworld.sh ).

In DOS, the PATH variable also exists, but the delimiter is a “;”.But at DOS, the command interpreter will always first look in the current directory, and ONLY in PATH.You can’t change this.

A run like this is done in the CURRENT directory, so no direct path like

SH/home/quora/desktop/color-calibration.sh

This is to be traced to the (.) for the slash

The slash is an indication for absolute path just like umbilical sign (~,/), as a beginner you can just use:

sh color-calibration.sh

Leave a Reply