Your SlideShare is downloading. ×
0
Shell Automation An Introduction toBash Shell Scripting      Anoop John
An Outline►Shell, interpreter, POSIX►Shell script operation►Commands, paths, returns►Variables, environments►Input, output...
Shell, Interpreter, POSIX►Kernel, Shell►Interprets commands►Command Line Interpreter / Command LineInterface►POSIX complia...
Free Software►Unix►GNU►GPL - Four freedoms ►Use, Modify, Distribute, Modify &  Redistribute►FSF►GNU / Linux
Shell Operation►Reads input from file, string (-c), or terminal►Breaks the input into words and operators►Parses the token...
Commands►Executables (ls)►Shell commands (cd, exit, pwd)►Return values►Command input►Command output►Path►Which
Variables & Environment►Setting a Variable►Environment (context)►Script►Eval►Exec►Source .►Strings, integers, arrays►Quoti...
Shell Script#!/bin/bashecho “Hello World”;name=Anoopecho “Hello $name”exit;
Arguments & Functions►Shell Scripts►Shell Arguments►Functions►Function Arguments
Shell Functionfunction log {  if [ $# ­gt 0 ]; then    echo "[$(date +"%D %T")] $@" >> $LOG_FILE    db "$@"  else     whil...
Input & Output►Stdin►Stdout►Pipes►Descriptors
Expressions►Assignment =►Arithmetic +, -, *, /, **,►Bitwise <<, >>, |, &, ~, ^►Logical !, &&, ||►Comparisons - Arithmetic ...
If Commandif [[ expression ]] then  commands;elif [[ expression ]] then  commands;else  commands;fi
Case Commandcase $ANIMAL in  horse | dog | cat)     echo ­n "four"    ;;  man | kangaroo )    echo ­n "two"   ;;  *)    ec...
For Loopfor NAME [in LIST ]; do   COMMANDS; donei=0for filename in `ls`; do   i=$(( i + 1));  printf "%­5s ­ %sn" $i “$fil...
While Loopwhile [[ expression ]]; do   COMMANDS; donei=0; while [[ $i ­lt 10 ]]; do  echo Counting $i;  ((i+=1));done;whil...
Shell Swiss Army Knives►awk►sed►grep►find►xargs►cat, less, tail, head, watch
Useful Commands►ps►top►kill►dmesg►curl, wget►chown, chmod, chgrp►uptime, top, nice, nohup
Getting help►man►help►command --help►Reading scripts►Mailing lists►User groups►Local community►Search the web
How to Start►Get GNU / Linux installed on your systems►Start using shell►Identify pain points in your daily operations►Aut...
Exempli Gratia►Drupal Backups►Asianet Autologin►Reliance Autologin►Secure Shared Folders
About Zyxware►Free Software Company►Software Development - Drupal►Leading Drupal Contributor from India►FSF Contributing M...
Thank You!   www.zyxware.com  info@zyxware.com     9446-06-9446
Upcoming SlideShare
Loading in...5
×

Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention, Sep 15, 2012

573

Published on

A workshop on "An introduction to BASH shell scripting". Conducted at CSI Students Convention at TKM College of Engineering, Kollam, Kerala on 15th September, 2012

http://www.zyxware.com/articles/3080/zyxware-conducts-workshop-on-bash-scripting-at-tkm-college-of-engineering-kollam

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
573
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention, Sep 15, 2012"

  1. 1. Shell Automation An Introduction toBash Shell Scripting Anoop John
  2. 2. An Outline►Shell, interpreter, POSIX►Shell script operation►Commands, paths, returns►Variables, environments►Input, output, pipes, descriptors►Expressions, conditions, loops►Awk, grep, sed, find, xargs►System utils►Examples
  3. 3. Shell, Interpreter, POSIX►Kernel, Shell►Interprets commands►Command Line Interpreter / Command LineInterface►POSIX compliance►Sh, Bourne Again, Brian Fox, FSF
  4. 4. Free Software►Unix►GNU►GPL - Four freedoms ►Use, Modify, Distribute, Modify & Redistribute►FSF►GNU / Linux
  5. 5. Shell Operation►Reads input from file, string (-c), or terminal►Breaks the input into words and operators►Parses the tokens into simple and compoundcommands►Performs the various shell expansions►Performs any necessary redirections►Executes the command►Optionally waits for the command to completeand collects its exit status
  6. 6. Commands►Executables (ls)►Shell commands (cd, exit, pwd)►Return values►Command input►Command output►Path►Which
  7. 7. Variables & Environment►Setting a Variable►Environment (context)►Script►Eval►Exec►Source .►Strings, integers, arrays►Quoting - single, double, escaping►Global, local
  8. 8. Shell Script#!/bin/bashecho “Hello World”;name=Anoopecho “Hello $name”exit;
  9. 9. Arguments & Functions►Shell Scripts►Shell Arguments►Functions►Function Arguments
  10. 10. Shell Functionfunction log {  if [ $# ­gt 0 ]; then    echo "[$(date +"%D %T")] $@" >> $LOG_FILE    db "$@"  else     while read data    do      echo "[$(date +"%D %T")] $data" >> $LOG_FILE       db "$data"    done  fi}log “Hello World!”echo “Hello World!” | log
  11. 11. Input & Output►Stdin►Stdout►Pipes►Descriptors
  12. 12. Expressions►Assignment =►Arithmetic +, -, *, /, **,►Bitwise <<, >>, |, &, ~, ^►Logical !, &&, ||►Comparisons - Arithmetic -eq, -ne, -lt, -gt, le►Comparisons - String =, !=, <, >, <=►Filesystem - -e, -f, -d, -x
  13. 13. If Commandif [[ expression ]] then  commands;elif [[ expression ]] then  commands;else  commands;fi
  14. 14. Case Commandcase $ANIMAL in  horse | dog | cat)     echo ­n "four"    ;;  man | kangaroo )    echo ­n "two"   ;;  *)    echo ­n "an unknown number of"   ;;esac
  15. 15. For Loopfor NAME [in LIST ]; do   COMMANDS; donei=0for filename in `ls`; do   i=$(( i + 1));  printf "%­5s ­ %sn" $i “$filename”;done;for name in Anoop John; do   echo “Hello ${name}”;done;
  16. 16. While Loopwhile [[ expression ]]; do   COMMANDS; donei=0; while [[ $i ­lt 10 ]]; do  echo Counting $i;  ((i+=1));done;while read linedo  echo $linedone < path/to/file
  17. 17. Shell Swiss Army Knives►awk►sed►grep►find►xargs►cat, less, tail, head, watch
  18. 18. Useful Commands►ps►top►kill►dmesg►curl, wget►chown, chmod, chgrp►uptime, top, nice, nohup
  19. 19. Getting help►man►help►command --help►Reading scripts►Mailing lists►User groups►Local community►Search the web
  20. 20. How to Start►Get GNU / Linux installed on your systems►Start using shell►Identify pain points in your daily operations►Automate through scripts►Join a mailing list►Ask & answer questions►Show off :-)
  21. 21. Exempli Gratia►Drupal Backups►Asianet Autologin►Reliance Autologin►Secure Shared Folders
  22. 22. About Zyxware►Free Software Company►Software Development - Drupal►Leading Drupal Contributor from India►FSF Contributing Member►Free Software Support in the local market►IT Training and FOSS Enabling►Websites & Email Services►IT Consultancy for Enterprises
  23. 23. Thank You! www.zyxware.com info@zyxware.com 9446-06-9446
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×