I need a shell script for spinning cursor which I can use with "copying" function. I tried below program and it works but the only problem I have here is that the spinner is showing below the text.
#!/bin/bash
spinner=('\' '/' '-' '\')
copy(){
echo "copying files..."
spin &
pid=$!
for i in `seq 1 10`
do
sleep 1
done
kill $pid
echo ""
}
spin(){
while [ 1 ]
do
for i in "${spinner[@]}"
do
echo -ne "\r$i"
sleep 0.2
done
done
}
copy
Expected Output: Copying files...\