1. Home
  2. Bash
  3. Bash Tutorial
  4. Bash – Shell Commands

Bash – Shell Commands

Shell Commands

Basically, a shell script is a collection of shell commands. You can simply run any bash shell command inside a shell script. In this tutorial, you will find some special ways to execute shell commands in a bash script to archive specific tasks.

Example 1

You can use any shell command under backquotes () and store their output in a variable.

$ VAR=date +"%d%b%Y"
$ echo $VAR


Example 2

You can also run any commands in backslashes with other commands. For example to create a directory with the current date in a script.

$ VAR=date +"%d%b%Y"
$ mkdir /backup/db/$VAR     

Or you can specify in single command.

$ mkdir /backup/db/date +"%d%b%Y"