문제

I have two identical shell script: A.sh , A , I want to know what is the difference ?

도움이 되었습니까?

해결책

You can even call it A.txt. Then give it execute permission and run it. If you give a .sh extension then others can easily identify that its a shell script.

다른 팁

As far as Linux based operating system, the extension does not make any special meaning. You can have any name for your file. You can execute the script with respective runtime.

For bash, sh sample.txt

For Python, python sample.txt

For NodeJS, node sample.txt

For better maintainability of the code, you have to name your filename with proper extension like .sh, .py, .js and etc.

Actually, Once your /path/to/anyfunnyfilename script has execution privileges, if you want to run it without calling the interpreter, you can have the FIRST line of your script like this:

#!/usr/bin/bash
code line 1
code line 2
...
code line n

it also apply for

#!/bin/perl
your perl code here

Another example:

#!/bin/python
your python code here

#!/bin/expect
your expect code here

And so on..

Hope this helps..

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top