#!/bin/bash
##Sorry for bad English.
##usage: script_name.sh silicon valley
##This urlencode fonction is from github project but I couldnt remember who is creator.
urlencode() {
# urlencode <string>
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%s' "$c" | xxd -p -c1 |
while read c; do printf '%%%s' "$c"; done ;;
esac
done
}
##In this case it doesnt requirement.
urldecode() {
# urldecode <string>
local url_encoded="${1//+/ }"
printf '%b' "${url_encoded//%/\x}"
}
a=$(lynx --dump "http://kat.cr/usearch/$(urlencode $@)"|grep "magnet"|sed "s/.*&dn=\([^&]*\).*//g"|sed "/^$/d")
line=$(wc -l < <(echo "$a"))
echo "no. of line $line"
for i in 03 05 06 07 08 09 10;do
if [[ $(echo "$a"|grep "silicon.valley.s03e$i.720p.hdtv.x265.hevc") ]];then #Also you can use variable for s03 but this is just example
echo "$a"|grep -n "silicon.valley.s03e$i.720p.hdtv.x265.hevc" #This will print like "8:silicon+valley+s03e03+720p+hdtv+x265+hevc+135mb+shaanig"
lineno=$(echo "$a"|grep -n "silicon.valley.s03e$i.720p.hdtv.x265.hevc"|cut -d: -f1)
link=$(echo "$a"|grep -n "silicon.valley.s03e$i.720p.hdtv.x265.hevc"|cut -d: -f2)
#notify-send -i $HOME/Desktop/flash/Flash.ico 'Flash is Running' "Getting silicon valley episode ${i}"
fi
done
Espero que isso lhe dê uma ideia de como você precisa usar esse script. Não codifique para cada letra apenas faça-o no laço. Além disso, se você repetir um par de comando basta adicionar uma função como esta
function repeating_command() {
echo $@ #this will print all argument
#grep -n "$(echo "$@"|cut -d" " -f2-)" $1 #I assume that first argument is filename Other args are for searched by grep.
echo FileName is $1
echo willSearchByGrep is $(echo "$@"|cut -d" " -f2-)
}
#example usage: repeating_command FileName silicon.valley