Hvorfor bruker folk "ekko" -kommandoen når du installerer programvare i Linux?

Innholdsfortegnelse:

Hvorfor bruker folk "ekko" -kommandoen når du installerer programvare i Linux?
Hvorfor bruker folk "ekko" -kommandoen når du installerer programvare i Linux?

Video: Hvorfor bruker folk "ekko" -kommandoen når du installerer programvare i Linux?

Video: Hvorfor bruker folk
Video: Alt du trenger å vite om Microsoft Forms - YouTube 2024, April
Anonim
Hvis du er ny på å bruke Linux, kan mange av kommandoene og variasjonene av dem virke litt forvirrende. Ta "echo" -kommandoen, for eksempel. Hvorfor bruker folk det når du installerer programvare? Dagens SuperUser Q & A-post har svaret på en ny Linux-brukeres spørsmål.
Hvis du er ny på å bruke Linux, kan mange av kommandoene og variasjonene av dem virke litt forvirrende. Ta "echo" -kommandoen, for eksempel. Hvorfor bruker folk det når du installerer programvare? Dagens SuperUser Q & A-post har svaret på en ny Linux-brukeres spørsmål.

Dagens Spørsmål & Svar-sesjon kommer til oss med høflighet av SuperUser-en underavdeling av Stack Exchange, en fellesskapsdrevet gruppering av Q & A-nettsteder.

Spørsmålet

SuperUser leser PallavBakshi vil vite hvorfor folk bruker "echo" -kommandoen når du installerer programvare på 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

Hvorfor bruker folk "echo" -kommandoen når du installerer programvare på Linux?

Svaret

SuperUser bidragsyter Fleet Command har svaret for oss:

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.

Har du noe å legge til forklaringen? Lyder av i kommentarene. Vil du lese flere svar fra andre tech-savvy Stack Exchange-brukere? Sjekk ut hele diskusjonstråden her.

Anbefalt: