Last active
January 5, 2016 06:00
-
-
Save ankur13secret/20ea6ff3a386d09c3c9e to your computer and use it in GitHub Desktop.
Learning Bash Scripting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bash [Bourne Again Shell] | |
Bourne Means Boundary | |
It is named so, because it supports user interaction and again a user can only interact with the script if it will wait for user. | |
Bash supports two modes | |
1. Interactive Mode(waits for user command, if required) &, | |
2. Non-Interactive Mode | |
File Descriptors are basically used to give instructions from outer world, e.g keyboards | |
There are basically three types of file descriptors:- | |
1. File Descriptor 0 : is called as standard input. This is where most process receives there input from input "connected" | |
2. File Descriptor 1 : is called as standard output. This is where most process sends the output. By default, it is connected to the display for output. | |
3. File Descriptor 2 : is called as standard error. This is where most process sends there error and informational messages. By default, it is connected to standard error which is connected to the display. | |
Even the total number of descriptors are not cnstant and it may increase as per the requirement. | |
Program : A program is a set pre-written set of instructions that can be executed by your system's kernel. A program gives kernels a direct instructions to execute. | |
Kernel : A kernel is also technically a program, but the one that continously runs and communicates with hardwares. | |
Streams : The flow of informations between files,devices and processes is called as streanms. | |
What's a bash script? : It's a file with bash code in it that can be executed by the kernel just like any other program on your | |
computer. In essence, it is a program in itself, although it does need the bash interpreter to do the work of translating the | |
bash language into instructions the kernel understands. | |
HashBang : It tells the kernel what interpreter it needs to use to understand the language in this file, and where to find it. We call it a | |
"hashbang" because it always begins with a "hash" # followed by a "bang" !. | |
A HashBang should be followed by a path which understand the way to run the scirpt file. Usually, we refer to /usr/bin/env which donot contain the logic to understand the script but it contains the path to the script. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment