Difference between revisions of "BASH"

From Script | Spoken-Tutorial
Jump to: navigation, search
(BASH Shell Scripting: Basic)
(BASH Shell Scripting: Intermediate)
Line 98: Line 98:
  
 
==BASH Shell Scripting: Intermediate==
 
==BASH Shell Scripting: Intermediate==
# Functions  
+
# Basics of Functions  
 
#*Writing your first shell function  
 
#*Writing your first shell function  
#*Displaying functions            
+
#*Displaying functions                        
#*Removing functions              
+
#*Writing functions
#*Defining functions             
+
#Function defintion           
#*Writing functions              
+
#*Calling functions
#*Calling functions             
+
#*Workflow of function
#*Pass arguments into a function
+
#*Illustration of work flow with an example(Example used: Machine details program)
#*Local variable                
+
#Local, global and passing Command line arguments in a function      
 +
#*Local variable in a function
 +
#*Global variable in a function
 +
#*Scope of local and global variables
 +
#*Demonstration of local and global variable by an example(Example used: Displaying complete name)
 +
#*Passing command line arguments
 +
#*Demonstration of passing command line arguments by an example(Example used: Displaying simple message)
 +
#Arrays and returning values in a function             
 
#*Returning from a function       
 
#*Returning from a function       
 
#*Source command                   
 
#*Source command                   
Line 134: Line 141:
 
#*Why use pipes                         
 
#*Why use pipes                         
 
#*Filters
 
#*Filters
 +
 
==BASH Shell Scripting: Advance==
 
==BASH Shell Scripting: Advance==
 
# Signals, process and traps  
 
# Signals, process and traps  

Revision as of 05:32, 23 October 2013

Bash is the shell, or command language interpreter, that will appear in the GNU operating system. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It offers functional improvements over sh for both programming and interactive use.

In addition, most sh scripts can be run by Bash without modification. The improvements offered by Bash include: Command line editing, Unlimited size command history, Job Control, Shell Functions and Aliases, Indexed arrays of unlimited size, Integer arithmetic.

In this tutorial we would mainly concentrate on how to use the wide variety of commands of Linux commands to handle files, directories, processes etc. These tutorials are created using Ubuntu version 12.04 and above. Please see the associated text box of individual spoken tutorials on the website to decide the versions of Linux OS to which it is applicable.

The contributors who helped create the outline, transcribe, create the tutorials are - Nancy Varkey, Ashwini Patil, Lavitha Monisha Pereira, Sachin Patil - all from IIT Bombay. The effort has been moderated and coordinated by the Spoken Tutorial team and FOSSEE team, IIT Bombay.



BASH Shell Scripting: Basic

  1. Introduction to BASH Shell Scripting
    • The bash shell
    • Bash Shell Script
  2. Basics of Shell Scripting
    • System variables
    • User defined variables
    • Accepting user input via keyboard
  3. Command Line arguments and quoting
    • Command Line arguments
    • Single quote
    • Double quote
    • Backslash
  4. Globbing and export statements
    • Globbing
    • The export statement
  5. Array Operations in BASH
    • Declaring an Array and Assigning values
    • Initializing an Array during declaration
    • To find length of Bash Array and length of nth element
    • To print whole Bash Array
    • Shell script to illustrate the concepts
  6. More on Arrays
    • Extraction of Array elements
    • Search and replace in an Array element
    • To Add an element to an Array
    • To remove an Element from an Array
    • Shell script to illustrate the concepts
  7. Conditional execution
    • Test
    • Syntax of test
    • if...then
    • Bash script example for if...then
    • if...then...else...if
    • if-else with a password program
  8. More on If loops
    • Nested if
    • Nested if with flowgraph
    • Nested If-else with Name and Password verification program
    • Multilevel if-then-else
    • Multilevel if-then-else with flowgraph
    • Multilevel if-else with String comparison program
  9. Logical Operations
    • Logical AND syntax
    • Logical AND workflow
    • Logical OR
    • Logical OR workflow
    • Logical OR and AND with string comparison program
    • Logical NOT syntax
    • Demonstration of logical NOT with an example(Example used: Checks whether a file exists)
  10. Bash comparison- Arithmetic comparison
    • Arithmetic comparison
    • -eq(equal to)
    • -ne(not equal to)
    • Demonstration of -eq and -ne with a word count program(Used: `wc -w`)
    • -lt(lesser than)
    • -le(lesser than or equal to)
    • -gt(greater than)
    • -ge(greater than or equal to)
    • Demonstration of -lt,-gt, -ge and -le with a word count program(Used: `wc -c`)
  11. Bash comparison- String & File attributes
    • String comparison
    • File attributes comparisons
  12. Loops
    • The for loop statement
    • The while loop statement
  13. More on Loops
    • Use of : to set infinite while loop
    • The until loop statement
    • The select loop statement
    • Exit the select loop statement
    • Using the break statement
    • Using the continue statement
  14. Case statement in BASH
    • Importance of case statement
    • Syntax of case(With both single and multiple options)
    • Work-flow of case statement
    • Creating menus using case
    • Case statement example
    • Illustration of case statement with simple test for checking disk space

BASH Shell Scripting: Intermediate

  1. Basics of Functions
    • Writing your first shell function
    • Displaying functions
    • Writing functions
  2. Function defintion
    • Calling functions
    • Workflow of function
    • Illustration of work flow with an example(Example used: Machine details program)
  3. Local, global and passing Command line arguments in a function
    • Local variable in a function
    • Global variable in a function
    • Scope of local and global variables
    • Demonstration of local and global variable by an example(Example used: Displaying complete name)
    • Passing command line arguments
    • Demonstration of passing command line arguments by an example(Example used: Displaying simple message)
  4. Arrays and returning values in a function
    • Returning from a function
    • Source command
    • Recursive function
    • Putting functions in background
  5. Redirections (error handling)
    • Input and Output
    • Standard input
    • Standard output
    • Standard error
    • Redirection of both standard error and output
    • Appending redirected output
    • Empty file creation
    • Here documents
    • Here strings
    • Assigns the file descriptor (fd) to file for output
    • Assigns the file descriptor (fd) to file for input
    • Closes the file descriptor (fd)
  6. Pipes and filters
    • Linking Commands
    • Multiple commands
    • Putting jobs in background
    • Pipes
    • How to use pipes to connect programs
    • Input redirection in pipes
    • Output redirection in pipes
    • Why use pipes
    • Filters

BASH Shell Scripting: Advance

  1. Signals, process and traps
    • Signals
    • What is a Process?
    • How to view Processes
    • Sending signal to Processes
    • Terminating Processes
    • Shell signal values
    • The trap statement
    • How to clear trap
    • Include trap statements in a script
    • Use the trap statement to catch signals and handle errors
    • What is a Subshell?
    • Compound command
    • Exec command
  2. Making you shell script interactive (using dialog box)
    • Menu driven scripts
    • Getting information about your system
    • Bash display dialog boxes
    • Dialog customisation with configuration file
    • A yes/no dialog box
    • An input dialog box
    • A password box
    • A menu box
    • A progress bar (gauge box)
    • The form dialog for input

Contributors and Content Editors

Ashwini, Lavitha Pereira, Nancyvarkey, PoojaMoolya