Difference between “./” and “sh” in UNIX

前端 未结 4 1058
鱼传尺愫
鱼传尺愫 2021-01-30 18:07

Sometimes i see that few scripts are executed through \"sh\" command and sometimes through \"./\" command.I am not able to understand the exact difference between them.Please he

4条回答
  •  -上瘾入骨i
    2021-01-30 18:18

    In simple words, sh file1 executing sh command/executable with file1 as a parameter. In this case file1 doesn't require execute privilege as sh executable read and intercept the commands in the file.

    ./file1 its nothing but running/executing an executable file file1, hence it requires executable privileges. In this case it executes on the shell mentioned in the shebang #!/bin/sh if its not mentioned then its on the current shell.

    Hoping the above statements are not chaos :)

提交回复
热议问题