Pregunta

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

¿Fue útil?

Solución

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.

Otros consejos

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..

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top