Bash

In Linux, while typing a command if you press TAB twice, it would list all available commands that starts with typed characters.

This is nothing new, probably you already know about this. This functionality is called bash completion. The basic file and directory name completion are available by default in bash command line.

But, we can turbo-charge this bash completion, and take it to the next level using complete command.

This tutorial explains how we can apply the auto-completion to options and to command’s arguments using programmable completion.
(more…)

5 Standard Completion Available in Linux Bash Command Line

by Balakrishnan Mariyappan on November 11, 2013

In Linux, by default Bash provides the following standard completion for users to use in the command line:

  1. Variablename completion
  2. Username completion
  3. Executable completion
  4. Filename and directory completion
  5. Hostname completion

(more…)

How to Encrypt Your Bash Shell Script on Linux Using SHC

by Ramesh Natarajan on May 15, 2012

Q: How do I encrypt my bash shell script on Linux environment? The shell script contains password, and I don’t want others who have execute access to view the shell script and get the password. Is there a way to encrypt my shell script?
(more…)

15 Linux Bash History Expansion Examples You Should Know

by Ramesh Natarajan on August 8, 2011

Bash history is very powerful. Understanding how to effectively use the bash history expansions will make you extremely productive on the Linux command line.

This article explains 15 examples that uses the following bash history expansion features:

  • Event designators – Refers to a particular command in the history. It starts with a !
  • Word designators – Refers to a particular word of a history entry. Typically this gets combined with an even designator. Even designators and word designators are separated by a colon
  • Modifiers – Modifies the result of the substitution done by the event or word designators

(more…)

12 Bash For Loop Examples for Your Linux Shell Scripting

by Ramesh Natarajan on July 11, 2011

There are two types of bash for loops available. One using the “in” keyword with list of values, another using the C programming like syntax.

This article is part of our on-going bash tutorial series.

This explains both of the bash for loop methods, and provides 12 different examples on how to use the bash for loop in your shell scripts.
(more…)

Bash has several commands that comes with the shell (i.e built inside the bash shell).

When you execute a built-in command, bash shell executes it immediately, without invoking any other program.

Bash shell built-in commands are faster than external commands, because external commands usually fork a process to execute it.

In this article let us review some useful bash shell builtins with examples.
(more…)

In bash shell, when you use a dollar sign followed by a variable name, shell expands the variable with its value. This feature of shell is called parameter expansion.

But parameter expansion has numerous other forms which allow you to expand a parameter and modify the value or substitute other values in the expansion process. In this article, let us review how to use the parameter expansion concept for string manipulation operations.

This article is part of the on-going bash tutorial series. Refer to our earlier article on bash { } expansion.
(more…)

5 Bash Case Statement Examples

by Sasikala on July 13, 2010

Bash shell case statement is similar to switch statement in C. It can be used to test simple values like integers and characters.

Case statement is not a loop, it doesn’t execute a block of code for n number of times. Instead, bash shell checks the condition, and controls the flow of the program.

In this article let us review the bash case command with 5 practical examples.
(more…)