為什麼人們在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
  • 閱讀 ( 47 )
  • 分類:網際網路

你可能感興趣的文章

如何在linux上查詢和修復損壞的包

... 什麼是包裝破損(broken packages)? ...

  • 發佈於 2021-03-11 11:30
  • 閲讀 ( 52 )

為什麼幾乎沒有人把linux稱為“gnu/linux”

...遇到了一個有趣的名字:GNU/Linux。這些字母是什麼意思,為什麼人們總是把它們附加到Linux上?我可以回答這個問題,同時,我也會把你帶到一場在Linux世界持續了幾十年的爭論當中。 ...

  • 發佈於 2021-03-13 20:45
  • 閲讀 ( 48 )

qubes os 3.2:最安全的linux作業系統

... 為什麼使用qubes作業系統? ...

  • 發佈於 2021-03-14 14:08
  • 閲讀 ( 46 )

為什麼使用哪種linux作業系統無關緊要

... 您使用哪些Linux作業系統?為什麼? ...

  • 發佈於 2021-03-15 05:08
  • 閲讀 ( 48 )

如何在linux上安裝軟體:軟體包格式說明

... 為什麼包格式這麼奇怪? ...

  • 發佈於 2021-03-17 09:44
  • 閲讀 ( 62 )

linux真的對病毒和惡意軟體免疫嗎?事實是這樣的

... 為什麼惡意軟體在linux桌面上不那麼常見 ...

  • 發佈於 2021-03-19 13:49
  • 閲讀 ( 58 )

6切換到linux時windows使用者需要接受的更改

... 為什麼?因為Linux發行版消耗的資源比Windows少得多。這就為激動人心的、快節奏的遊戲體驗留下了更多的資源! ...

  • 發佈於 2021-03-22 10:18
  • 閲讀 ( 51 )

如何在arch linux中安裝和刪除軟體包

...athub和Snap Store是兩個非常好的GUI應用程式,您可以使用它們在Linux機器上安裝軟體和應用程式。 ...

  • 發佈於 2021-03-28 02:18
  • 閲讀 ( 61 )

如何在ubuntu中安裝deb檔案?

... 在本文中,我們將探討什麼是deb檔案,以及如何透過桌面和終端上的幾種不同方法安裝或解除安裝deb檔案。我們還將探討如何更新它們,以及如何在BSD作業系統上安裝它們。 ...

  • 發佈於 2021-03-28 15:48
  • 閲讀 ( 63 )

如何在linux上使用chroot命令

...高系統的安全性。我們將向您展示最簡單的使用方法。 什麼是chroot? 如果您試圖衡量命令的有用性,則必須考慮它提供的功能及其易用性。如果它太複雜了,人們無法使用,或者太冗長了,以至於他們不想嘗試使用它,那麼...

  • 發佈於 2021-04-03 03:19
  • 閲讀 ( 69 )
minoroutcome
minoroutcome

0 篇文章

作家榜

  1. admin 0 文章
  2. 孫小欽 0 文章
  3. JVhby0 0 文章
  4. fvpvzrr 0 文章
  5. 0sus8kksc 0 文章
  6. zsfn1903 0 文章
  7. w91395898 0 文章
  8. SuperQueen123 0 文章

相關推薦