I'm trying to write a script to run one of my .jar
files as daemons, but I am not understanding how to create a .sh
extension file in Ubuntu. I have already used vi
to create a file with the code that I want, but I cannot figure out how to define the file to specifically be a .sh file. For example, I want to convert my file "foo
" or "foo.txt
" into "foo.sh
".
我正在尝试编写一个脚本来运行我的.jar文件之一作为守护进程,但我不知道如何在Ubuntu中创建.sh扩展文件。我已经使用vi创建了一个包含我想要的代码的文件,但我无法弄清楚如何将文件定义为特定的.sh文件。例如,我想将我的文件“foo”或“foo.txt”转换为“foo.sh”。
Is there a simple command I am not seeing that can convert files to a .sh extension or is it a more complicated process?
是否有一个简单的命令我没有看到可以将文件转换为.sh扩展名,还是一个更复杂的过程?
1 个解决方案
#1
14
Use this as a template:
将此作为模板使用:
#!/bin/bash
# content of your script
The first line is called a shebang and tells the OS what program that should be used executing the content of the file, in this case, bash
.
第一行称为shebang,告诉操作系统应该使用哪个程序来执行文件的内容,在本例中为bash。
To make the file executable:
要使文件可执行:
chmod 755 foo.sh
To execute your script do:
要执行你的脚本,请执行:
./foo.sh
#1
14
Use this as a template:
将此作为模板使用:
#!/bin/bash
# content of your script
The first line is called a shebang and tells the OS what program that should be used executing the content of the file, in this case, bash
.
第一行称为shebang,告诉操作系统应该使用哪个程序来执行文件的内容,在本例中为bash。
To make the file executable:
要使文件可执行:
chmod 755 foo.sh
To execute your script do:
要执行你的脚本,请执行:
./foo.sh