批处理文件和 Bash 文件之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5079180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between Batch and Bash files
提问by JCX
What are the differences between batch and bash?
批处理和 bash 之间有什么区别?
How are they being used?
它们是如何被使用的?
回答by Breton
"Batch File" is terminology normally used for a text file containing a sequence of MSDOS shell commands. Bash is a unix shell, and normally the equivalent term for unix to "Batch File" is "Shell Script", or simply "Script".
“批处理文件”是通常用于包含一系列 MSDOS shell 命令的文本文件的术语。Bash 是一个 unix shell,通常 unix 与“批处理文件”的等价术语是“Shell Script”,或者简称为“Script”。
I've never heard the term "Bash file", though it makes some logical sense, usually "Shell Script" or "Bash Script" is used instead.
我从未听说过“Bash 文件”这个词,尽管它有一定的逻辑意义,但通常使用“Shell 脚本”或“Bash 脚本”来代替。
回答by Paused until further notice.
"Batch" can mean several things (ignoring the general, non-technical definitions):
“批处理”可能意味着几件事(忽略一般的非技术定义):
A file containing MS-DOS or Windows command shell instructions in the form of a script. These will have filenames ending in ".BAT" for DOS or Windows or ".CMD" for Windows.
Linux/Unix also has a
batch
command. This is used to schedule the execution of a process when the system load falls below a threshold.Generically, a set of processes run as a group. This definition may be a little more tied to older systems such as those using punched cards, etc.
包含脚本形式的 MS-DOS 或 Windows 命令外壳指令的文件。对于 DOS 或 Windows,它们的文件名将以“.BAT”结尾,对于 Windows,它们将具有以“.CMD”结尾的文件名。
Linux/Unix 也有一个
batch
命令。这用于在系统负载低于阈值时调度进程的执行。通常,一组进程作为一个组运行。此定义可能与旧系统(例如使用穿孔卡片的系统等)联系更紧密。
From man bash
:
来自man bash
:
Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh).
Bash 是一种与 sh 兼容的命令语言解释器,它执行从标准输入或文件中读取的命令。Bash 还结合了来自 Korn 和 C shell(ksh 和 csh)的有用功能。
It's typically used on Linux or Unix (including OS X) systems, but it can be used on others, including Windows.
它通常用于 Linux 或 Unix(包括 OS X)系统,但也可以用于其他系统,包括 Windows。
回答by Barun
Bash
is actually a shell in UNIX/Linux. Batch files (or batch jobs) are usually referred to files containing list of commands executed periodically (daily, weekly, etc). You can write batch jobs in any language (example, Python, PHP, Perl, Shell script
). Bash
shell also supports scripting. So, you can write batch files with Bash
scripting also.
Bash
实际上是 UNIX/Linux 中的一个 shell。批处理文件(或批处理作业)通常是指包含定期(每天、每周等)执行的命令列表的文件。您可以使用任何语言(例如Python, PHP, Perl, Shell script
)编写批处理作业。Bash
shell 还支持脚本。因此,您也可以使用Bash
脚本编写批处理文件。
This is a broad idea without dealing with too much intricacies. :)
这是一个广泛的想法,无需处理太多复杂的问题。:)
回答by tkalve
Bash is a Unix shell. A bash file is a batch file, but not the other way around. A batch file is a text file containing a series of commands.
Bash 是一个 Unix shell。bash 文件是批处理文件,但反之则不然。批处理文件是包含一系列命令的文本文件。