Properly Naming a Bash Scripts

Last Updated on: July 31, 2020

Last week, I wrote a basic intro on bash shell scripting in this guide, we would take a look at how to name a script properly.

Let’s get this straight, we mostly do name things abruptly in the real world, but you might want to be careful in a shell world as things aren’t that black and white. When naming a script, you should not only give your script a sensible name, but you must also make sure it does not conflict with existing commands.

To give this a quick spin, try entering the following at the command prompt:

You’ll receive the following output:


devsrealm@server:~/bin$ type test
test is a shell builtin

The type command tells you what the shell will execute (and where it can be found if it is an external file) for any given command.

As you can see, a command called test already exists, so if you call your script test, it will not run at the shell prompt, as there is an existing one. However, script names often end in .sh; even so, there might be other scripts on your system with the same name as the one you chose.

You can also use which or whereis command to locate where the command is located, so, if I do which testI received /usr/bin/test

So, make sure you do proper checking before naming a script.




Comment policy: Respectful and beneficial comments are welcome with full open hands. However, all comments are manually moderated and those that doesn't relate with what the passage is saying or offensive comments would be deleted. Thanks for understanding!

Leave a Reply

Your email address will not be published. Required fields are marked *