【发布时间】:2018-12-15 10:20:00
【问题描述】:
我正在编写这样的更新脚本:
update.sh
#!/bin/bash
sudo echo
printf "### PACMAN\n" # I am running Arch Linux
sudo pacman -Syu
printf "\n### YAY\n"
yay -Syua
printf "\n### CUSTOM\n"
custom_script.sh # code below
custom_script.sh
#!/bin/bash
# [...]
wget --quiet --show-progress <some link>
# [...]
输出看起来像这样:
### PACMAN
<...>
:: Retrieving packages...
linux-lts-4.14.88-1-x86_64 60,8 MiB 725K/s 01:26 [########################################] 100%
<...>
### YAY
:: Searching AUR for updates...
there is nothing to do
### CUSTOM
:: Downloading custom updates...
somefile.txt 100%[================================================>] 20,92M 3,83MB/s in 5,6s
有没有办法让custom_script.sh 中的wget 命令以与pacman 相同的方式格式化进度条?我也愿意使用curl 或其他一些下载工具。
期望的输出:
### PACMAN
<...>
:: Retrieving packages...
linux-lts-4.14.88-1-x86_64 60,8 MiB 725K/s 01:26 [########################################] 100%
<...>
### YAY
:: Searching AUR for updates...
there is nothing to do
### CUSTOM
:: Downloading custom updates...
somefile.txt 20,9 MiB 3,8M/s 00:05 [########################################] 100%
【问题讨论】:
-
可能你需要看看这个 - github.com/raoddhjav/progressbar。可能正是您所需要的
-
@Inian:非常感谢,这对您有很大帮助,您可以在下面的帖子中看到 :) 虽然链接中有一点错误:它是 roddhjav,而不是 raoddhjav
标签: bash curl format wget pacman-package-manager