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

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

有时运行命令(随机)后可以看到这些行:

[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

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

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

答案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&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'

相关内容