Kāpēc cilvēki izmanto komandu "echo", instalējot programmatūru Linux?

Satura rādītājs:

Kāpēc cilvēki izmanto komandu "echo", instalējot programmatūru Linux?
Kāpēc cilvēki izmanto komandu "echo", instalējot programmatūru Linux?

Video: Kāpēc cilvēki izmanto komandu "echo", instalējot programmatūru Linux?

Video: Kāpēc cilvēki izmanto komandu
Video: The Last Reformation - The Beginning (2016) - FULL MOVIE - YouTube 2024, Aprīlis
Anonim
Ja jūs esat jauns Linux lietošanā, daudzas komandas un to varianti var šķist nedaudz mulsinoši. Piemēram, ņemiet komandu "echo". Kāpēc cilvēki to izmanto, instalējot programmatūru? Šodienas SuperUser Q & A ziņai ir atbilde uz jaunu Linux lietotāja jautājumu.
Ja jūs esat jauns Linux lietošanā, daudzas komandas un to varianti var šķist nedaudz mulsinoši. Piemēram, ņemiet komandu "echo". Kāpēc cilvēki to izmanto, instalējot programmatūru? Šodienas SuperUser Q & A ziņai ir atbilde uz jaunu Linux lietotāja jautājumu.

Šodienas jautājumu un atbilžu sesija mums priecājas par SuperUser - Stack Exchange dalību, kas ir kopienas vadīta Q & A tīmekļa vietņu grupa.

Jautājums

SuperUser lasītājs PallavBakshi vēlas uzzināt, kāpēc lietotāji Linux komandas instalēšanas laikā izmanto komandu "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 https://packages.ros.org/ros/ubuntu $(lsb_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

Kāpēc cilvēki instalē Linux programmatūru, izmantojot komandu "echo"?

Atbilde

SuperUser atbalstītājs Fleet Command ir atbilde mums:

Ordinarily, the function of the “echo” command is to display a string (piece of text) on the console. 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, $(lsb_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.

Vai kaut ko pievienot paskaidrojumam? Skatieties komentāros. Vēlaties lasīt citas atbildes no citiem tehnoloģiju savvy Stack Exchange lietotājiem? Šeit skatiet pilnu diskusiju pavedienu.

Ieteicams: