Create a shell script version of 'pokemonsay'

I didn't like the script written in python. I feel like I didn't do
it quite right. The mess with pipes confuses me. It is so much
simpler to handle pipes using shell script, in my opnion.

The shell script version of 'pokemonsay' is tiny if compared to the
python version. And it does the same thing.
This commit is contained in:
Lucas Possatti
2015-06-11 00:13:01 -03:00
parent bee5231bae
commit e28cf1f7fd

17
pokemonsay.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
# Define where the pokemon are.
pokemon_path=`pwd`/cows
# Find all pokemon in the pokemon path and choose a random one.
pokemon=$(find $pokemon_path -name "*.cow" | shuf -n1)
# Get the pokemon name.
filename=$(basename "$pokemon")
pokemon_name="${filename%.*}"
# Call cowsay.
cowsay -f $pokemon
# Write the pokemon name.
echo $pokemon_name