Created
September 27, 2016 09:01
-
-
Save DYelamos/bb664638a737d17b9d969acbed241649 to your computer and use it in GitHub Desktop.
BASH short exercise to show while, for loops, ifs and parameter parsing.
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 | |
if [ $# -eq 1 ]; then | |
foo=$1 | |
while [ true ]; do | |
for (( i=0; i<${#foo}; i++ )); do | |
letter="${foo:$i:1}" | |
done | |
sleep 2 | |
foo=$(cat /usr/share/dict/words | grep ^$letter. | sort -R | head -1) | |
echo $foo | |
done | |
else | |
echo "wrong paramethers" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment