You may want to have a quick command for personal use, on your Linux machine. Say you want a quick custom converter between currencies, or a quick calculation of time, or anything that you do regularly in your head that you would love to have a terminal command for.
The steps to create a command are simple:
- In any folder of your own, create a file with the name of the command.
- Open the file with any text editor and write a simple script that does what you need and outputs your result.
For example, a simple multiplier for quick conversions:
if [ $# -eq 0 ]
echo “No arguments supplied”
echo $1 hours = $converted minutes
- Copy the finished script to your local bin (which is usually part of your PATH already).
sudo cp mycommand /usr/local/bin/
Now you can execute your command just by opening terminal and typing the command name along with the arguments.
eg. mycommand 10