Kodėl žmonės naudoja "echo" komandą diegdami programinę įrangą Linux?

Turinys:

Kodėl žmonės naudoja "echo" komandą diegdami programinę įrangą Linux?
Kodėl žmonės naudoja "echo" komandą diegdami programinę įrangą Linux?

Video: Kodėl žmonės naudoja "echo" komandą diegdami programinę įrangą Linux?

Video: Kodėl žmonės naudoja
Video: HOW TO HOMEGROUP WITHOUT HOMEGROUP in Windows 10 - April 2018 Update - YouTube 2024, Gegužė
Anonim
Jei neseniai naudojate "Linux", daugelis jų komandų ir variantų gali atrodyti šiek tiek klaidinantys. Paimkite "echo" komandą, pavyzdžiui. Kodėl žmonės jį naudoja diegdami programinę įrangą? Šiandien "SuperUser" Q & A įrašas turi atsakymą į naują "Linux" vartotojo klausimą.
Jei neseniai naudojate "Linux", daugelis jų komandų ir variantų gali atrodyti šiek tiek klaidinantys. Paimkite "echo" komandą, pavyzdžiui. Kodėl žmonės jį naudoja diegdami programinę įrangą? Šiandien "SuperUser" Q & A įrašas turi atsakymą į naują "Linux" vartotojo klausimą.

Šiandieninė klausimų ir atsakymų sesija pateikiama su "SuperUser" - "Stack Exchange", bendruomenės valdoma Q & A grupių asociacija.

Klausimas

"SuperUser" skaitytuvas PallavBakshi nori sužinoti, kodėl žmonės naudoja "echo" komandą diegiant programinę įrangą "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

Kodėl žmonės naudoja komandą "echo" diegiant programinę įrangą "Linux"?

Atsakymas

"SuperUser" autorius "Fleet Command" mums atsakė:

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.

Ar turite ką nors įtraukti į paaiškinimą? Garsas išjungtas komentaruose. Norite skaityti daugiau atsakymų iš kitų "Tech-savvy Stack Exchange" vartotojų? Patikrinkite visą diskusijų temą čia.

Rekomenduojamas: