Created
December 9, 2018 16:48
-
-
Save meysam81/f2d9062f54500905a7d691cd49d5a06f to your computer and use it in GitHub Desktop.
a bash script to gather p30download.com links to for download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ "$#" -ne 2 ]]; then | |
echo "usage pdlist <filename> <number_of_parts>" | |
exit 1 | |
fi | |
parts="$2" | |
filename="$1" | |
partnum=$(echo ${filename##*part}) | |
partnum=$(echo ${partnum%%.*}) | |
partnum=$(echo ${#partnum}) | |
for ((i = 1; i <= $parts; i++)); do | |
if [[ $partnum -eq 2 ]]; then | |
filenum=$([[ $i -gt 9 ]] && echo "$i" || echo "0$i") | |
elif [[ $partnum -eq 1 ]]; then | |
filenum="$i" | |
fi | |
newfilenum=$(echo $filename | sed "s|part[0-9]*|part$filenum|") | |
echo $newfilenum | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment