Shell Script

Check if a directory or file exists

How to check if a directory or file exists within shell script?

Summary

Within a shell script we can test for the presence of directories and files. In this article we look at the basics and the more exotic options available. Testing the presence and type of a file can be done using the test command. For shell scripts, it is more common to use the [ command. Yes, it is an actual command. However, it may also be available as a so-called builtin and part of the shell.

Strip one or more characters from a variable or output

Want to delete one or more characters from a variable or piped output? There are multiple ways to achieve this using standard system utilities.

Making scripts (more) secure and safe

When you create a shell script, many things can go wrong. With a few basics you can catch errors easier and at the same time make your scripts (more) failsafe.

Summary

When you create a shell script, many things can go wrong. With a few basics you can catch errors easier and at the same time make your scripts (more) failsafe. The beauty of shell scripting is that with just a few steps this can be achieved! Empty variables: nounset (-u) A very typical issue in shell scripts is an incorrect or empty variable. Usually this happens due to a typo, but sometimes also assignments can be wrong.

Shell scripting

From beginnergs up to advanced users, these articles will cover your needs when it comes to creating better shell scripts.

Summary

Shell scripting is a powerful way to assist in automation of repeating tasks. While fairly easy to learn, the shell scripting language has a lot of caveats. In this area we collect tips and tricks to help you creating better shell scripts.

Prompt for user input in a shell script

How to prompt users in your shell script, like asking answer Yes or No? In this article we look at options to achieve this.

Summary

Shell scripts can be powerful for automation. Sometimes, we want to ask the user for input. Let’s have a look at a few options that can be very handy for your next shell script! Fill a variable with input provided by the user If we like the user to provide us with some details, like a name, email address, or hostname, we can use the read command. read -p "What is your name?