The bash case statement can be used when you have multiple choices conditions. Using bash case statement, it will be more readable and easier to maintain instead of nested if statements. This tutorial shows you the basics and use of the Bash case statement in shell scripts. The Bash case statement has a similar concept
bash - Page 3 of 4 - DesignLinux
Echo Command in Linux with Examples
In Linux, the echo command is most common and frequently used command. It will print the passed arguments to the standard output. Generally, echo command is used in shell scripts to show a message or output the results of other commands. echo Command# By default, the echo is built-in in Bash and other shells like
Bash For Loop
Loop is the basic requirement of any programming languages. Loops are useful when you want to execute a series of commands until the certain condition is satisfied. In Bash, loops are useful for automating repetitive tasks. In this tutorial, we will see basics of for loop in Bash. There are three basic loop constructs, for
Bash if..else Statement
The if statement is the most basic concepts of any programming language. In Bash, you can also use if…else, if…elif.else and nested if statements like other programming languages. In this article, we will show you the basics of the Bash if statement and use of it in your shell scripts. if Statement# If statement can
Bash Exit Command and Exit Code
In this article, we will discuss about the Bash exit built-in command and the exit code of the executed commands. Generally, at the time of writing Bash scripts, you will need to terminate the script when a certain condition is met or to take action based on the exit code of a command. Exit Status#
Bash Source Command
The source is a shell built-in command which is used to read and execute the content of a file, passed as an argument in the current shell script. It is useful to load functions, variables, and configuration files into shell scripts. Source Command Syntax# The following is the basic syntax for the Source Command: source
Bash: Append to File
This tutorial explains how to append text to a file in Bash. There are different ways to append text to a file. Prerequisite# Your user must have write permission to a file in which you want to append text. Otherwise, you will receive a permission denied error. Append Text using Redirection Operator (>>)# Using Redirection
How to Check if a File or Directory Exists in Bash
While working with Bash and shell scripts, you might need to check whether a directory or a file exists or not on your filesystem. In order to check whether a file or a directory exists with Bash, you can use test command. Following is the basic syntax for the test command: test EXPRESSION [ EXPRESSION
Bash Exit Command and Exit Codes
Often when writing Bash scripts, you will need to terminate the script when a certain condition is met or to take action based on the exit code of a command. In this article, we will cover the Bash exit built-in command and the exit statuses of the executed commands. Exit Status # Each shell command
How to Redirect stderr to stdout in Bash
When redirecting the output of a command to a file or piping it to another command, you might notice that the error messages are printed on the screen. In Bash and other Linux shells, when a program is executed, it uses three standard I/O streams. Each stream is represented by a numeric file descriptor: 0