• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention, Sep 15, 2012
 

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

on

  • 893 views

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 ...

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

Statistics

Views

Total Views
893
Views on SlideShare
886
Embed Views
7

Actions

Likes
0
Downloads
6
Comments
0

2 Embeds 7

http://www.linkedin.com 6
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

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

    • Shell Automation An Introduction toBash Shell Scripting Anoop John
    • 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
    • Shell, Interpreter, POSIX►Kernel, Shell►Interprets commands►Command Line Interpreter / Command LineInterface►POSIX compliance►Sh, Bourne Again, Brian Fox, FSF
    • 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 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
    • 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►Quoting - single, double, escaping►Global, local
    • 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     while read data    do      echo "[$(date +"%D %T")] $data" >> $LOG_FILE       db "$data"    done  fi}log “Hello World!”echo “Hello World!” | log
    • Input & Output►Stdin►Stdout►Pipes►Descriptors
    • Expressions►Assignment =►Arithmetic +, -, *, /, **,►Bitwise <<, >>, |, &, ~, ^►Logical !, &&, ||►Comparisons - Arithmetic -eq, -ne, -lt, -gt, le►Comparisons - String =, !=, <, >, <=►Filesystem - -e, -f, -d, -x
    • 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"   ;;  *)    echo ­n "an unknown number of"   ;;esac
    • 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;
    • 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
    • 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►Automate through scripts►Join a mailing list►Ask & answer questions►Show off :-)
    • 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 Member►Free Software Support in the local market►IT Training and FOSS Enabling►Websites & Email Services►IT Consultancy for Enterprises
    • Thank You! www.zyxware.com info@zyxware.com 9446-06-9446