Я пытаюсь создать индикатор выполнения или какой-то значок загрузки, чтобы показать, что создается хэш, а не пустой экран, ничего не происходит ... Вот что у меня есть:
if [[ $hashing != "y" && $hashing != "Y" ]]; then
echo -e "\n"
sudo dd if=dev/"$source" | md5sum
read -r compareresult
i=1
sp="/-\|"
echo -n ' '
while true
do
printf "\b${sp:i++%${#sp}:1}"
done
exit
fi ;;
Здесь используется вращающееся колесо для представления значка загрузки. И это действительно работает, используя то, что указано выше. Но не сейчас? Не уверен, что заказ неправильный или я что-то упустил. Любая помощь была бы огромной, спасибо
#!/bin/bash
#Clone_Command
while true
do
sudo -s
echo "==========================="
echo " Clone Command "
echo "==========================="
echo -e "\n"
echo -e "\n"
echo "Enter 1 for source device"
echo "Enter 'a' to hash source device"
echo "Enter 2 for destination device"
echo "Enter 3 to list all available disks"
echo "Enter 4 to execute dd command"
echo "Enter 5 to compare MD5 hashes"
echo "Enter q to exit"
echo -e "\n"
echo "PLEASE NOTE LISTING ALL DISKS WILL REQUIRE YOU TO RELOAD THE SCRIPT"
echo -e "\n"
echo -e "Enter your choice \c"
read -r choice
case "$choice" in
q) exit;;
1) echo -e "Enter source device '/dev/---'
Enter the last 3 letters of the device eg - sdf or sdb etc"
read -r source ;;
a) echo -e "Hashing this device may take a while depending on size"
echo -e "\n"
echo -e "Press enter if you wish to hash this device"
read -r hashing
if [[ $hashing != "y" && $hashing != "Y" ]]; then
echo -e "\n"
sudo dd if=dev/"$source" | md5sum
read -r compareresult
i=1
sp="/-\|"
echo -n ' '
while true
do
printf "\b${sp:i++%${#sp}:1}"
done
exit
fi ;;
2) echo -e "Enter destination device '/dev/---'
Enter the last 3 letters of the device eg - sdf or sdb etc"
read -r destination ;;
3) echo -e "Press enter to list all available disks \c"
read -r answ
if [[ $answ != "y" && $answ != "Y" ]]; then
clear
sudo lshw -class disk
exit
fi ;;
4) echo -e "This will format $destination. If you wish to continue press enter \c"
read -r ans
if [[ $ans != "y" && $ans != "Y" ]]; then
echo -e "\n"
sudo dd if=/dev/"$source" of=/dev/"$destination" bs=4096 status=progress
exit
fi ;;
5) echo -e "If you wish to compare MD5 Hash of both USBs then press 'Enter'\c"
read -r compare
if [[ $compare != "y" && $compare != "Y" ]]; then
echo -e "\n"
echo -e "Please note this is not a quick process"
echo -e "n"
md5sum -c <<<"$compareresult /dev/$destination"
fi ;;
esac
done