Introduction In this article, I will explain you 6 Bash shell command line Chaining Operators (Linux operator). Now let’s discuss what is chaining operator. Chaining operator is something which helps to run multiple commands at once like we execute a script and task completes automatically. Usually, people use Bash shell command line Chaining Operators (Linux operator) in shell scripting but also we can use these operators on shell prompt. Here we are going to discuss on below Bash shell … [Read more...] about 6 Bash Shell Command Line Chaining Operators in Linux
Shell Scripting
What are Shell Scripts? How to Create Shell Scripts?
What Is a Shell? A shell is a program that provides an interface between a user and an operating system (OS) kernel. An OS starts a shell for each user when the user logs in or opens a terminal or console window. What Is a Shell Script? A shell script is a file that contains shell and UNIX commands. Similar to compiled executable programs, the shell script has a specific purpose and is reusable. When the commands in the shell script are ordered and error-free, you can execute the shell … [Read more...] about What are Shell Scripts? How to Create Shell Scripts?
Understanding Positional Parameters (Passing Parameters/Arguments to Shell script)
The execution of scripts is made versatile by the ability to run a script based on arguments supplied on the command line. In this way, the operation of the script varies depending on what arguments are given to the script. The shell automatically assigns special variable names, called positional parameters, to each argument supplied to a script on the command line. The positional parameter names and meanings are shown in Table below. Positional Parameter Name Returns true (0) if: $0The … [Read more...] about Understanding Positional Parameters (Passing Parameters/Arguments to Shell script)
Bash if loop examples (if then fi, if then elif fi, if then else fi)
The if Statement The if statement allows you to specify courses of action to be taken in a shell script, depending on the success or failure of some command. It is a conditional statement that allows a test before performing another statement. The syntax for the simplest form is: if [ condition ] then block_of_statements fi Here, The condition in the if statement often involves a numerical or string test comparison, but it can also be any command that returns a status of 0 when it … [Read more...] about Bash if loop examples (if then fi, if then elif fi, if then else fi)
What is the purpose of .bash_profile file under User Home Directory In Linux
What is the purpose of ~/.bash_profile file Apart from having a home directory to create and store files, users need an environment that gives them access to the tools and resources. When a user logs in to a system, the user’s work environment is determined by the initialization files. These initialization files are defined by the user’s startup shell, which can vary depending on the release. The default initialization files in your home directory enable you to customize your working … [Read more...] about What is the purpose of .bash_profile file under User Home Directory In Linux
Understanding Variables in Bash Shell Under Linux
What are Variables? A variable is a temporary storage area in memory that is either set by the user, shell, system, or any program that loads another program. There are two categories of variables: The environment variables are valid for the duration of the session. The shell variables apply only to the current instance of the shell and are used to set short-term working conditions. Note: When a shell variable follows the dollar $ sign character, the shell interprets that the value … [Read more...] about Understanding Variables in Bash Shell Under Linux
How to use command redirection under Linux
Shell metacharacters Shell metacharacters are specific characters, generally symbols, that have special meaning within the shell. The metacharacters supported in bash are listed as follows: | : Sends the output of the command to the left as the input to the command on the right of the symbol & : Runs the process in the background, allowing you to continue working on the command line ; : Allows you to list multiple commands on a single line, separated by this character () : Groups commands … [Read more...] about How to use command redirection under Linux
How to use shell expansions for generating shell tokens under Linux
Shell Expansions While working in a shell, sets or ranges of information are often repeated. Shell expansion helps generate a large number of shell tokens using compact syntaxes. The expansion is performed on the command line after the command is split into tokens. Of the many expansions available, the path name, file name, and brace expansions are explained ahead. Path Name Expansion The pathname expansion simplifies location changes within the directory hierarchy. The pathname expansion … [Read more...] about How to use shell expansions for generating shell tokens under Linux
How to use command line shell functions in Linux
Functions, a powerful feature of shell programming, is a group of commands organized by common functionality. These easy-to-manage units, when called return a single value, and do not output anything. Using a function involves two steps: 1. Defining the function 2. Invoking the function Shell function Vs shell alias Shell functions and aliases are different on two counts. - aliases do not take arguments as functions do. - if a command name is defined as a function and an alias, the … [Read more...] about How to use command line shell functions in Linux
How to use shell aliases in Linux
What is an alias An alias is a shorthand shell notation that allows you to customize and abbreviate commands. Aliases are available in all shells. A common syntax to define an alias on command line is as follows: $ alias name=command_string If the first word on the command line is an alias, the shell replaces that word with the text of the alias. The shell maintains a list of aliases that it searches when a command is entered. The following rules apply while creating an alias: There can … [Read more...] about How to use shell aliases in Linux