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:
17
pokemonsay.sh
Executable file
17
pokemonsay.sh
Executable 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
|
||||
Reference in New Issue
Block a user