Zašto ljudi upotrebljavaju naredbu "echo" prilikom instaliranja softvera u Linux?

Sadržaj:

Zašto ljudi upotrebljavaju naredbu "echo" prilikom instaliranja softvera u Linux?
Zašto ljudi upotrebljavaju naredbu "echo" prilikom instaliranja softvera u Linux?

Video: Zašto ljudi upotrebljavaju naredbu "echo" prilikom instaliranja softvera u Linux?

Video: Zašto ljudi upotrebljavaju naredbu
Video: Privacy, Security, Society - Computer Science for Business Leaders 2016 - YouTube 2024, Travanj
Anonim
Ako ste novi u korištenju Linuxa, mnoge naredbe i njihove varijacije mogu se činiti pomalo zbunjujućim. Uzmite npr. Naredbu "echo". Zašto ga ljudi koriste prilikom instalacije softvera? Današnji SuperUser Q & A post ima odgovor na novo pitanje Linux korisnika.
Ako ste novi u korištenju Linuxa, mnoge naredbe i njihove varijacije mogu se činiti pomalo zbunjujućim. Uzmite npr. Naredbu "echo". Zašto ga ljudi koriste prilikom instalacije softvera? Današnji SuperUser Q & A post ima odgovor na novo pitanje Linux korisnika.

Današnja pitanja i odgovori nam se javljaju zahvaljujući SuperUseru - podjele Stack Exchange-a, zajednice-driven grupiranja Q & A web stranica.

Pitanje

SuperUser čitač PallavBakshi želi znati zašto ljudi koriste "echo" naredbu prilikom instalacije softvera u Linuxu:

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

Zašto ljudi upotrebljavaju naredbu "echo" prilikom instaliranja softvera u Linux?

Odgovor

Fleet Command za suradnika SuperUser ima odgovor za nas:

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.

Imate li nešto za objašnjenje? Zvuči u komentarima. Želite li pročitati više odgovora od drugih tehnoloških korisnika Stack Exchangea? Pogledajte ovdje cijelu raspravu.

Preporučeni: