-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextwget.sh
46 lines (39 loc) · 979 Bytes
/
extwget.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# If there are any arguements or not
if [ $# -eq 0 ];
then
echo "No arguments supplied"
else
# Passed arguement
PASSED=$1
# If arguement passed is accidentally a directory
if [ -d "${PASSED}" ];
then
echo "$PASSED is a directory";
else
# If arguement passed is a file
if [ -f "${PASSED}" ];
then
# Extracting lines from textfile
# Counting lines
LINES=$(cat $PASSED | wc -l)
LINES=`expr $LINES + 1`
# Looping through each line and using wget to fetch them
i=1
while [ $i -lt $LINES ]
do
URL=$(head $PASSED -n $i | tail -n 1)
echo "$i : $URL"
wget -c $URL
i=`expr $i + 1`
done
else
# Wget on multiple arguements
for n in $(seq 1 $#); do
echo "Downloading: $1"
wget -c $1
shift
done
fi
fi
fi