bash中这些额外的输出行是什么?


9

在某些时候,运行命令后(随机)可以看到这些行:

[1]-  Done                    wget -c http://downloads.sourceforge.net/project/zorin-os/9/zorin-os-9-core-32.iso?r=http%3A%2F%2Fzorinos.com%2Fdownload9.html
[2]+  Done                    ts=1460659842

第一行是命令本身,并非总是发生。但是有时命令行应用程序会停止运行而不会返回命令行,直到我按Enter键为止。显示这些行。

直到一周前,我的系统才出现这种情况。这有问题吗?

Answers:


20

您可能发出了以下命令:

wget -c http://downloads.sourceforge.net/project/zorin-os/9/zorin-os-9-core-32.iso?r=http%3A%2F%2Fzorinos.com%2Fdownload9.html&ts=1460659842&something-else

该命令包含特殊字符&,用于同时运行多个进程。该命令被解释为三个(或更多)命令:

# First command (the one that you see after [1]):
wget -c http://downloads.sourceforge.net/project/zorin-os/9/zorin-os-9-core-32.iso?r=http%3A%2F%2Fzorinos.com%2Fdownload9.html
# Second command (the one that you see after [2]):
ts=1460659842
# Third command (the one which output should be above the "Done" lines):
something-else

这是一个示例,可以帮助您更好地理解:

# Here I'm launching three 'echo' commands, the first two in background, the third in foreground
andrea@andrea-laptop:~$ echo first & echo second & echo third
[1] 5033    # This is bash telling me that the first process was started with job number 1 and PID 5033
first       # This is the output from the first process
[2] 5034    # This is bash telling me that the second process was started with job number 2 and PID 5034
third       # This is the output from the third process
second      # This is the output from the second process
andrea@andrea-laptop:~$ 
[1]-  Done                    echo first    # This is bash telling me that the first background job has quit
[2]+  Done                    echo second   # This is bash telling me that the second background job has quit

您应该正确引用URL以避免这种情况和其他讨厌的影响:

wget -c 'http://downloads.sourceforge.net/project/zorin-os/9/zorin-os-9-core-32.iso?r=http%3A%2F%2Fzorinos.com%2Fdownload9.html&ts=1460659842&something-else'

6
还有一个原因,您永远不要盲目地复制粘贴终端命令...有人可以在URL someurl.com/index.php&malicious-command-here-URL上运行,人们就会运行它并破坏他们的系统。
Nzall '16
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.