lundi 23 décembre 2019

How to create a loop before downloading a file checking your current file?

This is how I started. Something easy.

a="abc"
b="ABC"

if [ "$a" == "$b" ]; then
    echo "Strings $a & $b match"
else
    echo "Strings $a don't match $b"
fi

Then I tried this. In which it always states skipping even if I haven't yet downloaded it.

input="file"
while IFS= read -r line; do
path="${line%/*}"
file="${line##*/}"

if [ $line = $file ]; then
     echo "skipping ${file##*/}"
else
     wget -nc -q --show-progress "${path}/${file}"
  sleep 1
fi
done < "$input"

I also tried this. I know this is wrong because I have nothing for y to match x. I was trying to use y as a variable in wget to match something in my file x.

for x in $(cat file); do
for y in ???; do

if [ "$x" == "$y" ]; then
     echo "${x##*/} & ${y##*/} match skipping download"
else
     echo "${x##*/} don't match ${y##*/} downloading"
  sleep 1
     wget -q -nc --show-progress "$y"
fi
done
done

I really just want to run a basic loop being able to check my file as I'm downloading. Skip file if already there and if not download file.

Aucun commentaire:

Enregistrer un commentaire