Що це за додаткові вихідні лінії в 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; який показує ці рядки.

Моя система не поводилася так до тижня тому. Це проблема?

Відповіді:


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-тудь, і люди просто запустять його та зламають свою систему.
Nzall
Використовуючи наш веб-сайт, ви визнаєте, що прочитали та зрозуміли наші Політику щодо файлів cookie та Політику конфіденційності.
Licensed under cc by-sa 3.0 with attribution required.