Shell Commands

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
04Sep2017

Example 2

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

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

Or you can specify in a single command.

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

Post a Comment

0 Comments

close