简体   繁体   English

在shell命令中echo是什么意思?

[英]what does echo - - - mean in shell command?

I have the following command: 我有以下命令:

echo "- - -" | sudo tee /sys/.../scan

How do I interpret this line of command? 我如何解释这一行命令? I couldn't find anything in Google because the characters in my line. 我在Google中找不到任何内容,因为该行中的字符。

Thanks! 谢谢!

echo "- - -"

print three dashes and two spaces to the screen 在屏幕上打印三个破折号和两个空格

|

a pipe - take output of the left-hand command (echo) and feed it as input to the right-hand command (sudo). 管道-取得左手命令(echo)的输出,并将其作为右手命令(sudo)的输入。

sudo

run a specified command with root privileges root权限运行指定的命令

tee

the specified command, which will be run as the root user. 指定的命令,它将以root用户身份运行。 Tee accepts input from its stdin (being fed the echo output via the pipe), and splits it into two outputs: the first goes to the screen, so you see - - - printed in your terminal, and also outputs to a specified file, /sys/.../scan in this case. Tee接受来自其stdin的输入(通过管道输入回声输出),并将其分为两个输出:第一个进入屏幕,因此您看到- - -打印在终端中,还输出到指定的文件, /sys/.../scan在这种情况下/sys/.../scan

Since you haven't provided the full path to the /sys file, can't tell WHICH scan it is, but generally speaking, this command is probably telling the OS to rescan some hardware bus for changes (additions/removals). 由于您尚未提供/sys文件的完整路径,因此无法告诉它是哪个,但一般而言,此命令可能告诉OS重新扫描某些硬件总线以查找更改(添加/删除)。

Check the first answer here: 在这里检查第一个答案:

https://askubuntu.com/questions/192461/ubuntu-server-12-04-hotplug-sata-automount https://askubuntu.com/questions/192461/ubuntu-server-12-04-hotplug-sata-automount

From the link: On Linux, you can tell the system to rescan an individual SATA port.So to rescan the SATA3 port 通过链接: On Linux, you can tell the system to rescan an individual SATA port.So to rescan the SATA3 port

echo "- - -" simply outputs - - - to the standard output. echo "- - -"仅将- - -输出到标准输出。 The tee command (whose name comes from the plumbing T-pipe) splits the output two ways: once to its own standard output, and also to the specified file. tee命令(其名称来自管道T形管)将输出分成两种方式:一次到自己的标准输出,再到指定文件。 sudo serves to run tee as the root user, in order to be able to write to the system file in /sys . sudo用作root用户运行tee ,以便能够写入/sys的系统文件。

To recap, echo "- - -" | sudo tee some_file 回顾一下, echo "- - -" | sudo tee some_file echo "- - -" | sudo tee some_file will: echo "- - -" | sudo tee some_file将:

  1. write - - - to some_file , as the root user. 以root用户身份将- - -写入some_file

  2. repeat the same output to standard output, presumably for logging/debugging purposes. 将相同的输出重复到标准输出,大概是出于记录/调试的目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM