如何使bash中的进度条保持在屏幕上?

时间:2014-06-13 17:27:27

标签: bash user-interface progress-bar sh

我是bash脚本的新手,我想制作一个简单的进度条

init pb
do stuff
pb add 10%
do other stuff
...

但是,午餐的脚本会打印一些日志,我不希望进度条消失,我希望它留在屏幕的底部。这可能吗?

非常感谢,

亚瑟

这是我的代码:

#!/bin/bash
echo 'Welcome to autoIrc'
echo 'This will automaticly create a gephi file for you'
echo 'I suggest running the script in a screen if you are with ssh'
# Are you sure ?
location=`pwd`
echo "We are in $location. Do you want to install the script there ? [Y/n]"
read -p 'Y/n >' confirm
if [ $confirm != "Y" ]
then
    echo "I am exiting"
    exit
fi
clear
echo 'Cleaning up...'
echo -e "\e[100m"
echo "We are in $location."
echo "Files list here:"
echo `ls ./`
echo "File list in ../"
echo `ls ../`
rm ./ircsnapshot -R
echo -e "\e[49m"
clear
# Okay, now, go on
echo 'First, a bit of config'
read -p "Please enter the bot nickname >" nickname
read -p "Please enter the bot username >" username
read -p "Please enter the bot realname >" realname
read -p "Now, please enter the number of seconds between commands >" throttle
read -p "Please enter the server adress >" server

# Git, python, toilet
echo 'Downloading dependencies. You may have to enter your SU password.'
echo -e "\e[100m"
sudo apt-get update -y && apt-get install -y git python toilet
echo -e "\e[49m"
clear
echo 'Dependencies are now installed.'

# Main script
echo 'Cloning the script from github to here'
echo -e "\e[100m"
git clone https://github.com/bwall/ircsnapshot.git
echo -e "\e[49m"
cd "./ircsnapshot/ircsnapshot"
location=`pwd`
echo "We are in $location."
echo "Files list here:"
echo `ls ./`
echo "File list in ../"
echo `ls ../`
echo -e "\e[41m"
rm ./example.png
echo -e "\e[49m"
clear
# GeoIP data
echo "I will download the database"
echo -e "\e[100m"
wget -O geolite.zip http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.zip
echo -e "\e[49m"
clear
echo 'Download complete. Unzipping'
echo -e "\e[100m"
unzip geolite.zip -d ./GeoLiteData
echo -e "\e[49m"

mv ./GeoLiteData/*/* ./GeoLiteData

clear
echo "Is it OK ?"
ping -c 1 $server
# script
clear
echo "We are in $location."
echo "Files list here:"
echo `ls ./`
echo "File list in ../"
echo `ls ../`
echo "I will lunch the script now It will print some lines and take some time'"
echo -e "\e[100m"
python "./ircsnapshot.py" "-n $nickname" "-u $username" "-r $realname" "$server"
echo -e "\e[49m"
# 2nd script
echo 'Great !'
clear
echo "I'll now convert the json generated to something readable by gephi"
echo "This will take some time"
echo -e "\e[100m"
sudo chmod +x ./to.gexf.py
var=$(./to.gexf.py -m "./GeoLiteData" "UserToLink" "./$server.json")
echo -e "\e[49m"
clear
echo 'Good.'
gexf="./$server.gexf"
echo "$var" >> "$gexf"
echo "Here it is : ./ircsnapshot/ircsnapshot/$gexf"
toilet -t --filter gay Finished install !
exit

编辑:“重复”不会显示位于屏幕底部的进度条

0 个答案:

没有答案