Sun Nov 13, 2016 8:45 am
Sun Nov 13, 2016 9:03 pm
Mon Nov 14, 2016 7:14 am
if lynx -dump -nolist http://main.mepis-deb.org/MX14packages.html | grep "$search_term"
then
FOUND="yes"
printf "$search_term found in community repo http://main.mepis-deb.org/MX14packages.html \n"
fi
code]
repo_list=(
http://teharris.net/NewPackages.html
http://main.mepis-deb.org/MX15packages.html
http://main.mepis-deb.org/MX14packages.html
)
#----------------------------------------------------------
for i in ${repo_list[*]}
do
# if echo "$i"
if lynx -dump -nolist "$i" | grep "$searchterm"
then
FOUND="yes"
printf "\n$searchterm found in $i\n"
fi
done
Mon Nov 14, 2016 8:23 pm
Mon Nov 14, 2016 10:35 pm
# find files in current directory modified more than 30 days ago:
find . -type f -mtime +30
# find files in current directory modified in the last 10 days:
find . -type f -mtime -10
if find . -name myfile -mtime +7 ; then
if lynx -blah > myfile ; then
grep whatever
print whatever
fi
else
grep whatever
print whatever
fi
Tue Nov 15, 2016 10:22 am
user$ find . -name dragora_repos.txt -mtime +7
user$ echo $?
0
user$ rm dragora_repos.txt
user$ touch dragora_repos.txt
user$ if find . -name dragora_repos.txt -mtime +7; then echo "elder than a week"; fi
elder than a week
user$
Tue Nov 15, 2016 11:08 am
#!/usr/bin/bash
### Trying to implement a text file to crawl_mepis.sh
### so we don't have to download all repos each time we run it
### **** knows if this works reliable
### hence it's actual tmp-name is: hack_crawl_mepis :-)
# 1) make sure search_term is given as argument
if [ "$#" -ne 1 ]
then
printf "\nEnter program you search for as argument\n" 1>&2
exit 1
fi
#----------------------------------------------------------
# 2) set variables
search_term="$1"
found=""
log_file="mepis_repos.txt"
#shorter URL list for testing purposes
repo_list=( http://teharris.net/NewPackages.html
http://main.mepis-deb.org/MX15packages.html
http://main.mepis-deb.org/MX14packages.html )
# 3) if this is the first run, mepis_repo.txt doesn't exist
# run lynx to downlad
if [ ! -f "$log_file" ]
then
for i in "${repo_list[@]}"
do
if lynx -dump -nolist "$i" | tee -a "$log_file" | grep "$search_term"
then
found="yes"
printf "\n%s found in $i\n" "$search_term"
fi
done
# if mepis_repos.txt exists, check it's been last updated
# if elder than x days, lynx dump the repos again
# else just grep through the file
else
if [ $(find . -name "$log_file" -mtime +7) ]
then
rm "$log_file"
for i in "${repo_list[@]}"
do
if lynx -dump -nolist "$i" | tee -a "$log_file" | grep "$search_term"
then
found="yes"
printf "\n%s found in $i\n" "$search_term"
fi
done
else
grep "$search_term" "$log_file"
fi
fi
Tue Nov 15, 2016 3:37 pm
Tue Nov 15, 2016 3:53 pm