我对使用终端真的很陌生,我一直盲目地遵循指南,却不知道为什么要这样做以及它做什么。.尽管本指南可以帮助我安装vmware player。
这对我有用,因为使文件可执行文件,单击文件并运行。
sudo sh vmwareplayer.txt (将其更短)
我不知何故sudo会sh做什么,但会做什么?没有它,它将变为“找不到vmwareplayer.txt”。对于捆绑文件,为什么以.txt结尾?
sh在调用脚本的命令中做什么。这个问题是关于脚本文件内部如何#!工作的。完全不同。
我对使用终端真的很陌生,我一直盲目地遵循指南,却不知道为什么要这样做以及它做什么。.尽管本指南可以帮助我安装vmware player。
这对我有用,因为使文件可执行文件,单击文件并运行。
sudo sh vmwareplayer.txt (将其更短)
我不知何故sudo会sh做什么,但会做什么?没有它,它将变为“找不到vmwareplayer.txt”。对于捆绑文件,为什么以.txt结尾?
sh在调用脚本的命令中做什么。这个问题是关于脚本文件内部如何#!工作的。完全不同。
Answers:
在Ubuntu中,sh或/bin/sh仅指向dash。sh应该运行dash用于Ubuntu的默认命令解释器。1 dash是指Debian Almquist外壳。
Shell是系统的命令行解释器。还有其他一些炮弹一样bash,csh,zsh等这里是从man页面简要摘录dash:
The shell is a command that reads lines from either a file or the termi‐ nal, interprets them, and generally executes other commands. It is the program that is running when a user logs into the system (although a user can select a different shell with the chsh(1) command). The shell imple‐ ments a language that has flow control constructs, a macro facility that provides a variety of features in addition to data storage, along with built in history and line editing capabilities. It incorporates many features to aid interactive use and has the advantage that the interpre‐ tative language is common to both interactive and non-interactive use (shell scripts). That is, commands can be typed directly to the running shell or can be put into a file and the file can be executed directly by the shell.
关于Linux Shell的教程很多,您可以从Wikipedia Article开始。
遇到您的问题,如果您编写sh file,dash则会file为您执行。
我相信没有一个较早的答复者回答您实际问过的问题G,所以我会对此进行介绍。sh如前所述,在执行程序时插入,将在非交互式子shell中执行程序。非交互式外壳的行为(例如,初始化)与运行程序时所使用的标准交互式外壳不同。
老实说,我不知道这有什么实际效果。如您所见sh vmwareplayer.txt,(通常)能够在同一文件夹中执行某些操作,而仅仅键入vmwareplayer.txt(通常)则无法。那必须要做外壳环境;它不是shell或subshell本身固有的任何质量。您当然可以直接以root用户身份在当前目录中执行程序sudo ./vmwareplayer.txt。以我的经验,这总是和sudo sh vmwareplayer.txt。我希望有人会来解释为什么有时需要子外壳。
该sh实用程序是命令语言解释器/命令,它执行从命令行字符串,标准输入或指定文件读取的命令。该应用程序确保要执行的命令以Shell命令语言中描述的语言表示。
例如:
下面的命令从字符串执行shell命令:
sh -c "cat myfile.txt"
即执行命令-cat myfile.txt
请参阅以下链接以获取详细说明:http : //pubs.opengroup.org/onlinepubs/009695399/utilities/sh.html