A linux shell script that can grab the pronunciation mp3 file of an input word.
You have installed grep, curl, sed and head in your system.
Simply run the following command to see the result:
$ chmod +x lookup.sh # give it exec permission
$ ./lookup.sh goodYou'll get an mp3 file whose name is good.mp3 in the current path and you can play it.
If you want to make this script a system command, you can add it to the PATH env.
You can do it like this on your computer:
Make a directory:
$ mkdir ~/binCopy the script to the directory:
$ cp lookup.sh ~/binAdd the following line to ~/.bashrc or ~/.zshrc(based on the shell you are using):
export PATH=$PATH:~/binRun the following command or restart your terminal:
$ source ~/.bashrcIf you are using zsh:
$ source ~/.zshrcNow you can use this script globally:
$ lookup.sh testBefore you run the script globally, make sure you have given it exec permission with the command:
$ chmod +x lookup.sh
If you want to download the mp3 files to a specific path, you can change the script:
...
wget -O /path/to/your/folder/$1.mp3 $url 2> /dev/null
...
echo /path/to/your/folder/$1.mp3Don't forget to create the folder for saving downloaded files before you run the script.