所以我制作了这个 bash 脚本来从网站下载多个文件,我想在后台下载这些文件,因此“-b 标志”。
脚本:list.sh
wget -b -O filename.jpg www.example.com/image1.jpg
wget -b -O filename2.jpg www.example.com/image2.jpg
wget -b -O filename3.jpg www.example.com/image4.jpg
如何一次执行一个命令?我想一次下载一个文件,然后在第一个文件完成后,我想下载第二个文件等。
当我运行时./list.sh
,它开始立即下载所有文件。
答案1
如果我理解正确的话,你想运行所有的后台脚本,所以:
#!/bin/bash
wget -O filename.jpg www.example.com/image1.jpg
wget -O filename2.jpg www.example.com/image2.jpg
wget -O filename3.jpg www.example.com/image4.jpg
然后:
$ screen
$ ./script
现在您可以断开与 Linux 计算机的连接,然后返回并检索会话:
$ screen -r
apt-cache show screen
[...]
Description-en: terminal multiplexer with VT100/ANSI terminal emulation
GNU Screen is a terminal multiplexer that runs several separate "screens" on
a single physical character-based terminal. Each virtual terminal emulates a
DEC VT100 plus several ANSI X3.64 and ISO 2022 functions. Screen sessions
can be detached and resumed later on a different terminal.
.
Screen also supports a whole slew of other features, including configurable
input and output translation, serial port support, configurable logging,
and multi-user support.