我试图压缩我的bash脚本我希望你们能帮助我。它是一个伪造网站黑客攻击的脚本。
# **Heres The Code** #
#!/usr/bin/bash
clear
echo -e "\e[32mWhat Website Do You Want to Hack\e[0m"
read website
if [[ $website = *".com"* ]] && [[ $website = *"www."* ]];
then
sleep 1s
clear
echo Now Initializing Packages
sleep 1s
clear
sleep .5s
echo Initializing Packages [#---------]
sleep .5s
clear
echo Initializing Packages [##--------]
sleep .5s
clear
echo Initializing Packages [###-------]
sleep .5s
clear
echo Initializing Packages [####------]
sleep .5s
clear
echo Initializing Packages [#####-----]
sleep .5s
clear
echo Initializing Packages [######----]
sleep .5s
clear
echo Initializing Packages [#######---]
sleep .5s
clear
echo Initializing Packages [########--]
sleep .5s
clear
echo Initializing Packages [#########-]
sleep .5s
clear
echo Initializing Packages [##########]
sleep .5s
clear
echo Now Receiving Packages
sleep 1s
clear
echo Receiving Packages [#---------]
sleep .5s
clear
echo Receiving Packages [##--------]
sleep .5s
clear
echo Receiving Packages [###-------]
sleep .5s
clear
echo Receiving Packages [####------]
sleep .5s
clear
echo Receiving Packages [#####-----]
sleep .5s
clear
echo Receiving Packages [######----]
sleep .5s
clear
echo Receiving Packages [#######---]
sleep .5s
clear
echo Receiving Packages [########--]
sleep .5s
clear
echo Receiving Packages [#########-]
sleep .5s
clear
echo Receiving Packages [##########]
sleep .5s
clear
echo Now Cracking Packages
sleep 1s
clear
echo Cracking Packages [#---------]
sleep .5s
clear
echo Cracking Packages [##--------]
sleep .5s
clear
echo Cracking Packages [###-------]
sleep .5s
clear
echo Cracking Packages [####------]
sleep .5s
clear
echo Cracking Packages [#####-----]
sleep .5s
clear
echo Cracking Packages [######----]
sleep .5s
clear
echo Cracking Packages [#######---]
sleep .5s
clear
echo Cracking Packages [########--]
sleep .5s
clear
echo Cracking Packages [#########-]
sleep .5s
clear
echo Cracking Packages [##########]
sleep .5s
clear
echo -e "\e[31mERROR FIREWALL\e[0m"
sleep 1s
clear
echo Attempt 2
sleep 1s
clear
echo -e "\e[34mNow Hacking $website\e[0m"
sleep 1s
clear
echo Hacking $website [#---------]
sleep .5s
clear
echo Hacking $website [##--------]
sleep .5s
clear
echo Hacking $website [###-------]
sleep .5s
clear
echo Hacking $website [####------]
sleep .5s
clear
echo Hacking $website [#####-----]
sleep .5s
clear
echo Hacking $website [######----]
sleep .5s
clear
echo Hacking $website [#######---]
sleep .5s
clear
echo Hacking $website [########--]
sleep .5s
clear
echo Hacking $website [#########-]
sleep .5s
clear
echo Hacking $website [##########]
sleep .5s
clear
ping -c 6 $website
sleep 1s
clear
sleep 1s
echo -e "\e[32mConnected To $website\e[0m"
sleep 1s
else
echo -e "\e[31mERROR INVAILD URL\e[0m"
fi
答案 0 :(得分:4)
为所有重复的代码使用循环。
hashes='##########'
dashes='----------'
for hashcount in {1..10}; do
clear
sleep .5s
dashcount=$((10-hashcount))
echo "Initializing Packages [${hashes:0:$hashcount}${dashes:0:$dashcount}]"
done