Last active
December 15, 2015 02:49
-
-
Save benbridts/5190262 to your computer and use it in GitHub Desktop.
Oplossingen examen computersystemen 2 (praktijk Linux)
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 | |
# | |
# Ben Bridts - 2013-03-18 | |
# | |
reset='\e[0m' | |
red='\e[0;31m' | |
yellow='\e[1;33m' | |
blue='\e[0;34m' | |
regex="([[:digit:]]{1,3})[%]" | |
IFS=`echo -en '\n\r'` | |
for line in `df` | |
do | |
if [ ${line:0:10} != "Filesystem" ] # headerline, no color | |
then | |
[[ $line =~ $regex ]] | |
use=${BASH_REMATCH[1]} | |
if [ $use -gt 90 ] | |
then | |
echo -en $red | |
elif [ $use -gt 70 ] | |
then | |
echo -en $yellow | |
elif [ $use -lt 10 ] | |
then | |
echo -en $blue | |
fi | |
fi | |
echo -e ${line}${reset} | |
done |
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 | |
# | |
# Ben Bridts - 2013-03-18 | |
# | |
function funemail { | |
grep -oe '\w[^ ]*@[^ ]*\w' $1 | |
} | |
count=0 | |
if [ -z $1 ] || [ ! -f $1 ] | |
then | |
echo "Usage: `basename ${0}` filename" >&2 | |
echo "Example: `basename ${0}` /usr/share/copyright" >&2 | |
else | |
for line in `funemail $1` | |
do | |
echo $line | |
count=$(($count +1)) | |
done | |
fi | |
echo "Er zijn $count e-mailadressen gevonden" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment