Skip to content

Instantly share code, notes, and snippets.

@markogresak
Created January 30, 2015 14:54
Show Gist options
  • Select an option

  • Save markogresak/1642d54cbe0a753ec989 to your computer and use it in GitHub Desktop.

Select an option

Save markogresak/1642d54cbe0a753ec989 to your computer and use it in GitHub Desktop.
#!/bin/bash
html=$(curl -s "http://www.uni-lj.si/akademije_in_fakultete/fakultete/")
function getNumbers {
echo $(egrep -o -E 'tel:.?[0-9\/\ \-]{12}?' <<< $html) | sed -E $'s/\ tel:[\ ]?/\\\ntel:/g'
}
function getNames {
echo $(egrep -o -E '<dl class="photo-list">.{1,}?<\/dl>' <<< $html) | egrep -o '(>[A-ZČŠŽ]+ - [A-Z\ a-z蚞ȊŽ]+<)' | sed -E $'s/(<|>)//g'
}
function lookupNumber {
echo -n "Vnesite ime željene fakultete: "; read name
match=$(echo "$(getNames)" | grep -in $name)
if [[ -n $match ]]; then
echo "Ujemanje z: $(cut -d':' -f 2 <<< $match)"
line=$(cut -d':' -f 1 <<< $match)
echo "$(getNumbers)" | sed -n "$line p"
else
echo "Niz se ne ujema z nobeno od fakultet."
fi
}
echo "1.)"
getNumbers
echo "2.)"
getNames
echo "3.)"
lookupNumber
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment