为什么人们在linux中安装软件时使用“echo”命令?

如果您是Linux新手,那么许多命令及其变体可能看起来有点混乱。以“echo”命令为例。为什么人们在安装软件时使用它?今天的超级用户问答帖子回答了一位Linux新用户的问题。...

为什么人们在linux中安装软件时使用“echo”命令?

如果您是Linux新手,那么许多命令及其变体可能看起来有点混乱。以“echo”命令为例。为什么人们在安装软件时使用它?今天的超级用户问答帖子回答了一位Linux新用户的问题。

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

问题

超级用户读者PallavBakshi想知道为什么人们在Linux中安装软件时使用“echo”命令:

I am new to the computing world. While installing ROS Indigo, the first step said that I should use the following code:

  • sudo sh -c ‘echo “deb http://packages.ros.org/ros/ubuntu $(l**_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’

Why do people use the “echo” command along with “sh -c” in this context? I have seen the “echo” command used in other installation processes as well.

Links I Looked Through

What Exactly is the “sh” Command?

Ubuntu Install of ROS Indigo

为什么人们在Linux中安装软件时使用“echo”命令?

答案

超级用户舰队司令部给了我们答案:

Ordinarily, the function of the “echo” command is to display a string (piece of text) on the c***ole. But this time, a (greater than) > character is added after the echo command, redirecting its output to a text file located in /etc/apt/sources.list.d/ros-latest.list.

Basically, this whole command writes a piece of text to a text file. Now, here comes the tricky part:

The string written to the file may be different for each computer. The part, $(l**_release -sc), is resolved (changed into something else) when the “echo” command runs.

You can open /etc/apt/sources.list.d/ros-latest.list in a text editor before and after the command to see the changes for yourself. Keep in mind that the file might not exist before using this command.


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-08 11:45
  • 阅读 ( 164 )
  • 分类:互联网

你可能感兴趣的文章

5 linux发行版,您可以在windows subsystem for linux中安装

... 您还可以同时运行不同的发行版,为什么不全部尝试呢? ...

  • 发布于 2021-03-10 22:31
  • 阅读 ( 314 )

如何在ubuntu linux中安装microsoft文本字体

... 这就是为什么你可能想要真正的东西。 ...

  • 发布于 2021-03-14 15:30
  • 阅读 ( 380 )

如何在ubuntu、fedora和mint中安装专有的图形驱动程序

... 为什么需要专有的图形驱动程序? ...

  • 发布于 2021-03-14 23:36
  • 阅读 ( 217 )

应该在虚拟机中尝试的7大linux操作系统

... 如果Lubuntu本身对你来说不够轻,为什么不试试LXLE,Lubuntu额外的寿命延长?LXLE甚至比Lubuntu更轻,非常适合在低规格但支持虚拟化的硬件上作为虚拟机运行。 ...

  • 发布于 2021-03-16 11:49
  • 阅读 ( 410 )

如何在linux和raspberry pi中安装usb闪存设备

... 在Ubuntu或Raspbian中安装USB闪存或SD卡有问题吗?告诉我们吧。 ...

  • 发布于 2021-03-17 16:00
  • 阅读 ( 204 )

如何使用windows subsystem for linux运行linux桌面

...是在Linux上使用Windows子系统,但它没有桌面环境。那么,为什么不安装自己的Linux发行版呢? ...

  • 发布于 2021-03-18 04:14
  • 阅读 ( 238 )

如何在ubuntu中安装和更改主题

... 如何在ubuntu中安装主题 ...

  • 发布于 2021-03-24 21:26
  • 阅读 ( 374 )

如何在arch linux中安装和删除软件包

想在Arch Linux上安装软件包但不知道如何安装?很多人在第一次从基于Debian的发行版迁移到Arch时都面临这个问题。但是,您可以使用包管理器在基于Arch的系统上轻松地管理包。 ...

  • 发布于 2021-03-28 02:18
  • 阅读 ( 468 )

如何在ubuntu中安装deb文件?

... 要在终端中安装deb文件,请打开包含deb文件的目录,然后使用以下命令激活dpkg: ...

  • 发布于 2021-03-28 15:48
  • 阅读 ( 509 )

如何在虚拟机中安装chrome操作系统

... 想再试一次吗?下面是如何在虚拟机中安装Windows10上的macOS。 ...

  • 发布于 2021-03-30 12:27
  • 阅读 ( 582 )
minoroutcome
minoroutcome

0 篇文章

相关推荐