File size: 658 Bytes
2972088
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad290eb
2972088
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

set -e

increment=20

first=$1
n_items=${2:-$increment}
offset=${3:-0}

first_to_fetch=$(($first + $offset))

first_index="$(printf '%04d' $first)"
last_index="$(printf '%04d' $(($first + $increment - 1)))"

folder="threads/$first_index-$last_index"

if test ! -d "$folder"; then
    mkdir $folder
fi

last_to_fetch=$(($first_to_fetch + $n_items - 1))

for i in $(seq $first_to_fetch $last_to_fetch); do
    printf "Fetching page %04d...\n" $i
    python -m much fetch $i -p "$folder" -i index.tsv
done

echo "Number of files in the directory '$folder': $(ls $folder | wc -l)"
echo "Number of lines in the 'index.tsv': $(cat index.tsv | wc -l)"