Perché le persone usano il comando "echo" durante l'installazione del software in Linux?

Sommario:

Perché le persone usano il comando "echo" durante l'installazione del software in Linux?
Perché le persone usano il comando "echo" durante l'installazione del software in Linux?

Video: Perché le persone usano il comando "echo" durante l'installazione del software in Linux?

Video: Perché le persone usano il comando
Video: Come creare rete domestica...senza impazzire!! ✨ - YouTube 2024, Aprile
Anonim
Se siete nuovi nell'usare Linux, molti dei comandi e le loro variazioni possono sembrare un po 'confusi. Prendi il comando "echo", per esempio. Perché le persone lo usano durante l'installazione del software? Il post di Q & A di SuperUser di oggi ha la risposta alla domanda di un nuovo utente Linux.
Se siete nuovi nell'usare Linux, molti dei comandi e le loro variazioni possono sembrare un po 'confusi. Prendi il comando "echo", per esempio. Perché le persone lo usano durante l'installazione del software? Il post di Q & A di SuperUser di oggi ha la risposta alla domanda di un nuovo utente Linux.

La sessione di domande e risposte di oggi ci viene fornita per gentile concessione di SuperUser, una suddivisione di Stack Exchange, un raggruppamento di domande e risposte basato sulla comunità.

La domanda

Il lettore SuperUser PallavBakshi vuole sapere perché la gente usa il comando "echo" durante l'installazione del software in Linux:

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

Perché le persone usano il comando "echo" quando installano il software in Linux?

La risposta

Il collaboratore di SuperUser Fleet Command ha la risposta per noi:

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.

Hai qualcosa da aggiungere alla spiegazione? Audio disattivato nei commenti. Vuoi leggere più risposte dagli altri utenti di Stack Exchange esperti di tecnologia? Controlla la discussione completa qui.

Consigliato: