media file explorer download upload index folder image licenses menu widget Play Pause profile-settings more dots-two-horizontal dots-two-vertical more-vertical pending google-plus hangouts facebook instagram whatsapp spotify telegram twitter vine renren rss youtube twitch vimeo flickr dribble behance deviantart 500px steam github soundcloud skype reddit linkedin lastfm delicious stackoverflow pinterest xing flattr foursquare yelp World

Properly Naming a Bash Scripts

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:

type test

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.