Linux版本的.cmd文件

时间:2021-08-31 01:55:42

I am creating a terminal program and cannot find out what the ending is for Linux. I know in windows it is .cmd. Any help would be great.

我正在创建一个终端程序,但无法找出Linux的结局。我知道在Windows中它是.cmd。任何帮助都会很棒。

Thank you.

谢谢。

2 个解决方案

#1


1  

Yes, you can remove the .sh at the end and it should work, generally using ./cmd will get it to run. this goes for C programs as well. You do not need to give an extension for the object file, You could then add a path to your bash file and then you can execute it as a normal command.

是的,您可以在结尾处删除.sh并且它应该可以正常工作,通常使用./cmd将使其运行。这也适用于C程序。您不需要为目标文件指定扩展名,然后可以添加bash文件的路径,然后可以将其作为普通命令执行。

Look here.

看这里。

https://*.com/a/8779980/2720497

https://*.com/a/8779980/2720497

#2


0  

You don't need a file extension on Linux, though typically, people use .sh (sh being short for 'shell').

您不需要在Linux上使用文件扩展名,但通常情况下,人们使用.sh(sh是'shell'的缩写)。

You can run it one of two ways:

您可以通过以下两种方式之一运行它:

bash myscript.sh 

or you can make the script itself executable and run it directly:

或者您可以使脚本本身可执行并直接运行它:

chmod a+x myscript.sh # make it executable
./myscript.sh # run it

Linux scripts' first line is typically #!/bin/bash which is the path to the specific shell used to run the script with the second method.

Linux脚本的第一行通常是#!/ bin / bash,它是用于使用第二种方法运行脚本的特定shell的路径。

#1


1  

Yes, you can remove the .sh at the end and it should work, generally using ./cmd will get it to run. this goes for C programs as well. You do not need to give an extension for the object file, You could then add a path to your bash file and then you can execute it as a normal command.

是的,您可以在结尾处删除.sh并且它应该可以正常工作,通常使用./cmd将使其运行。这也适用于C程序。您不需要为目标文件指定扩展名,然后可以添加bash文件的路径,然后可以将其作为普通命令执行。

Look here.

看这里。

https://*.com/a/8779980/2720497

https://*.com/a/8779980/2720497

#2


0  

You don't need a file extension on Linux, though typically, people use .sh (sh being short for 'shell').

您不需要在Linux上使用文件扩展名,但通常情况下,人们使用.sh(sh是'shell'的缩写)。

You can run it one of two ways:

您可以通过以下两种方式之一运行它:

bash myscript.sh 

or you can make the script itself executable and run it directly:

或者您可以使脚本本身可执行并直接运行它:

chmod a+x myscript.sh # make it executable
./myscript.sh # run it

Linux scripts' first line is typically #!/bin/bash which is the path to the specific shell used to run the script with the second method.

Linux脚本的第一行通常是#!/ bin / bash,它是用于使用第二种方法运行脚本的特定shell的路径。