什么是| (竖线字符)在shell(bash)命令中执行? [英] What does a | (pipe character) do in a shell (bash) command?
问题描述
我必须运行此命令来安装NPM.它有什么作用?什么是|最后呢?
I have to run this command to install NPM. What does it do? What is the | at the end?
curl https://raw.githubusercontent.com/creationix/nvm/v0.23.2/install.sh | bash
此外,我是否在Bash中运行类似UNIX的命令?为什么这样做? Bash是终端的UNIX命令兼容接口吗?
Also, am I running UNIX-like commands in Bash? Why does this work? Is it that Bash is a UNIX-command compatible interface for the terminal?
推荐答案
在bash(和大多数* nix外壳)中,|
(管道)符号取自一个命令的输出,并将其用作下一个命令的输入
In bash (and most *nix shells) the |
(pipe) symbol takes the output from one command and uses it as the input for the next command.
您在这里所做的就是使用curl检索install.sh文件,然后将其内容输出到bash中,该bash将执行install.sh的内容.
What you are doing here is using curl to retrieve the install.sh file and then output its contents into bash, which is a shell that will execute the contents of install.sh
简而言之,您正在下载并运行install.sh脚本.
In short, you are downloading and running the install.sh script.
这篇关于什么是| (竖线字符)在shell(bash)命令中执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!