TODO
1. Create a loading spinner
find out how to use arrays
learn to create scripts that run continuously
touch spinner && chmod u+x spinner && vim spinner
# !/usr/bin/env bash
# declare array
array=('-' '\' '|' '/')
# loop until stopped
while true; do
# for every element in the array
for c in "${array[@]}"; do
# man echo
# \-n do not output the trailing newline
# \-e enable interpretation of backslash escapes
echo \-en "\\r $c "
# wait for half a second
sleep .5
# close for
done
# close while
done
Run the script spinner
2. Creating a backup of your home
How to create a backup?
Creating an archive from a directory, adding also the date in the name.
tar --help
man tar
date
The script name will be BackUp1
Creating, adding permission and opening the file
touch BackUp1 && chmod u+x BackUp1 && vim BackUp1
# !/usr/bin/env bash
# create a backup of the home directory
tar -czf /tmp/home/backup`date +"%Y*%m_%d"` ~/sandbox
Task 1
Create a script wikiPython that reads a Wikipedia page - https://en.wikipedia.org/wiki/Python_(genus) (use curl command)
extracts Species elements - python name (what kind of pythons are there) - use
grepsave the output the to a new file
append to the new file the last line that is the count of species - using
wc
Task 2
Create a script weather.py that give you the weather from curl https://wttr.in/(location)
the location will be read from the keyboard - example
weather Bucharesttest that you have the location
test that location is a valid string and doesn’t contain numbers using a regex operator compare a variable with
$var =~ '^[0-9]+$'
Task 3
Create a health check script healthCheck that looks at:
dateand timethe
uptimeof the machinehow much disk
dfand memory usagefreetop most expensive process
run this every 2 seconds using
sleeporwatch
Task 4
Create a script that reads the file source_code/scripting/data/ip.txt and:
Find out how many different IPs?
How many exit different codes?
How many occurrences of each exit code?
How often an IP appears?
Which IP has experienced the most successes and failures?
Task 5
Create a script that reads the file source_code/scripting/data/hadoop.log and:
Find out how many INFO, WARN ERROR messages are, and print the percentage compared to the total lines
Which error appears most frequently?
Are there any weird messages in the log?
Task 6
Create a script randomWords.sh that generated with 1000 random words file from the /usr/share/dict/words
use
shufcommand to generate random wordsuse
headcommand to get the first 1000 wordscount all the words that have 9 characters using
awkandwc
Task 7
Create a Makefile that has the following targets:
install- that installs the scripthealthCheckin/usr/local/bin
uninstall- that removes the scripthealthCheckfrom/usr/local/bin
test- that runs the scripthealthCheckand saves the output to a filehealthCheck.log