-n Do not output the trailing new line. -e Enable interpretation of the following backslash escaped characters in the strings:

Similar documents
Module # 14 References:

Oracle Shell Scripting Linux And Unix Programming For Oracle Oracle In Focus Series Volume 26

Here Scripts. Writing An HTML File With A Script

CS 25200: Systems Programming. Lecture 10: Shell Scripting in Bash

What is UNIX? A Little Bit about UNIX and User Interfaces. Adapted from Practical Unix and Programming Hunter College

2. UDP Client, UDP Server

B.Sc. (Computer Applications) Vocational - First Year. II Application Software hrs III Practical (Windows, Word, Excel, Power Point)

Course Outline. TERM EFFECTIVE: Fall 2016 CURRICULUM APPROVAL DATE: 11/23/2015

Learning The Bash Shell: Unix Shell Programming (In A Nutshell (O'Reilly)) PDF

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

Filemaker Pro Design & Scripting For Dummies Free Download PDF

Introduction to Linux Basics Part II. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

T. Y. B. C. A. Semester 5 Effective From: June 2013.

Bourne Shell Reference

ACHARYA NAGARJUNA UNIVERSITY B.Sc., (ERP, Multimedia and Web Designing) CBCS from st Year 2nd Semester - E R P

UNIX, GNU/Linux and simple tools for data manipulation

KLS s Gogte Institute of Technology, Udyambag, Belagavi. CLO 1: To provide introduction to UNIX Operating System and its File System

Mastering UNIX Shell Scripting

Korn Shell Unix And Linux Programming Manual Third Edition Pdf

Essential Linux Shell Commands

The Linux Programming Interface: A Linux And UNIX System Programming Handbook Ebooks Free

CPS221 Lecture: Operating System Functions

CSE II-Sem)

Linux for Beginners. Windows users should download putty or bitvise:

ITT Technical Institute. CS120 Programming in Visual Basic Onsite Course SYLLABUS

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

Shell script. Shell Scripts. A shell script contains a sequence of commands in a text file. Shell is an command language interpreter.

DOWNLOAD OR READ : UNIX FOR MAC OS X 10 4 TIGER VISUAL QUICKPRO GUIDE PDF EBOOK EPUB MOBI

Introduction: What is Unix?

Bash print to stderr

Gujarat University M. Sc. Computer Science [S. F.] Semester-1 Syllabus Gujarat Arts & Science College, Ahmedabad.

1. Introduction to PHP 1.1 Installation of PHP and mysql 1.2 PHP configuration in IIS & Apache Web Server and features of PHP

Mastering Windows Powershell Scripting Second Edition One Stop Guide To Automating Administrative Tasks

Mastering Windows Powershell Scripting Second Edition One Stop Guide To Automating Administrative Tasks

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009

PHP by Pearson Education, Inc. All Rights Reserved.

Deccan Education Society s FERGUSSON COLLEGE, PUNE (AUTONOMOUS) SYLLABUS UNDER AUTONOMY. FIRST YEAR B.Sc. COMPUTER SCIENCE SEMESTER I

COMP 4/6262: Programming UNIX

Python Class-Lesson1 Instructor: Yao

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

Unix Shells and Other Basic Concepts

Read & Download (PDF Kindle) The Art Of UNIX Programming

TOP 10 FREE PYTHON PROGRAMMING BOOKS - DOWNLOAD PDF OR

Introduction to Linux

Manual Shell Script Linux If Not Exist Directory Does

Lec 1 add-on: Linux Intro

COMP 2718: The OS, Shell, Terminal, and Text

Prof. Navrati Saxena TA: R. Sachan

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

12.1 UNDERSTANDING UNIX SHELL PROGRAMMING LANGUAGE: AN INTRODUCTION Writing a Simple Script Executing a Script

Linux & Shell Programming 2014

Chapter 2, Part I Introduction to C Programming

Read & Download (PDF Kindle) System Programming With C And Unix

do shell script in AppleScript

Lecture 8. Introduction to Shell Programming. COP 3353 Introduction to UNIX

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc.

Bash Reference Manual

Mac OS X Part 2. The University of Utah Student Computing Labs Macintosh Support

Teaching and Examination Scheme: PAPER HRS TH TU PR TH PR OR TW TOTAL

Linux Command Line and Shell Scripting Bible

Linux shell scripting Getting started *

How To Use The UNIX-LINUX Vi Text Editor: Tips, Tricks, And Techniques (And Tutorials Too!) By Larry L. Smith READ ONLINE

CS246 Spring14 Programming Paradigm Notes on Linux

Name of chapter & details

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

CSC 280 Operating System Principles

AC109/AT109 UNIX & SHELL PROGRAMMING DEC 2014

Free Downloads Learning The UNIX Operating System, Fifth Edition

Introduction to the Shell

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Introduction to Bash Programming. Dr. Xiaolan Zhang Spring 2013 Dept. of Computer & Information Sciences Fordham University

System Administration

1. Hello World Bash Shell Script. Last Updated on Wednesday, 13 April :03

Manual Shell Script Linux If Not Equals. Statement >>>CLICK HERE<<<

Subcontractors. bc math help for the shell. interactive or programatic can accept its commands from stdin can accept an entire bc program s worth

Prefix COMP Course# 421 Title Unix for Programmers Units (3) 3 hours lecture per week 3 hours lecture per week

S E C T I O N O V E R V I E W

BEGINNER SQL PROGRAMMING USING MICROSOFT SQL SERVER 2012

BEGINNER SQL PROGRAMMING USING MICROSOFT SQL SERVER 2016

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

Bash scripting Tutorial. Hello World Bash Shell Script. Super User Programming & Scripting 22 March 2013

hrs. Designing Fundamentals 2 Paper-II: Data base hrs. management Systems Semester IV 3 Paper-I: Web

Shell Script Programming 2

VEER NARMAD SOUTH GUJARAT UNIVERSITY, SURAT D. C. A. (1 st SEMESTER) SYLLABUS

Manual Shell Script Linux If Not Equal String Comparison

Bash Reference Manual Reference Documentation for Bash Edition 2.5b, for Bash Version 2.05b. July 2002

COMS 6100 Class Notes 3

Chapter 4. Unix Tutorial. Unix Shell

RH033 Red Hat Linux Essentials

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Linux at the Command Line Don Johnson of BU IS&T

Linux & Shell Programming 2014

Linux shell scripting intro/review

Proposed syllabus for

Introduction to Linux Part 2b: basic scripting. Brett Milash and Wim Cardoen CHPC User Services 18 January, 2018

Essential System Administration: Tools And Techniques For Linux And Unix Administration, 3rd Edition PDF

CS Unix Tools & Scripting

Linux Operating System

Transcription:

References: [1] S. Jain, 100 Shell Programs in Unix. Pinnacle Technology, 2009. [2] M. Garrels, Bash Guide for Beginners (Second Edition). Fultus Corporation, 2010. [3] Isrd, Basics Of Os Unix And Shell Programming. Tata McGraw-Hill Education, 2006. [4] P. Seebach, Beginning Portable Shell Scripting: From Novice to Professional. Apress, 2008. [5] E. Foster-Johnson, J. C.Welch, and M. Anderson, Beginning Shell Scripting. John Wiley & Sons, 2007. [6] A. Robbins and N. H. F. Beebe, Classic Shell Scripting: Hidden Commands that Unlock the Power of Unix. O Reilly Media, Inc., 2005. [7] R. Peters, Expert Shell Scripting. Apress, 2009. [8] M. G. Venkateshmurthy, Introduction to Unix and Shell Programming. Pearson Education India, 2005. [9] G. Festari, Learning Shell Scripting with Zsh. Packt Publishing Ltd, 2014. [10] C. Newham, Learning the bash Shell: Unix Shell Programming. O Reilly Media, Inc., 2005. [11] B. Rosenblatt and A. Robbins, Learning the Korn Shell. O Reilly Media, Inc., 2002. [12] W. E. S. Jr, Linux Command Line. NO STARCH Press, 2012. [13] R. Blum and C. Bresnahan, Linux Command Line and Shell Scripting Bible. John Wiley & Sons, 2015. [14] R. Blum and C. Bresnahan, Linux Command Line and Shell Scripting Bible. John Wiley & Sons, 2015. [15] S. Lakshman, Linux Shell Scripting Cookbook. Packt Publishing Ltd, 2011. [16] S. Tushar, Linux Shell Scripting Cookbook. Packt Publishing Ltd, 2013. [17] K. O. Burtch, Linux Shell Scripting with Bash. Sams, 2004. [18] R. K. Michael, Mastering Unix Shell Scripting: Bash, Bourne, and Korn Shell Scripting for Programmers, System Administrators, and UNIX Gurus. John Wiley & Sons, 2011. [19] C. Johnson, Pro Bash Programming: Scripting the Linux Shell. Apress, 2009. [20] S. Veeraraghavan, Sams Teach Yourself Shell Programming in 24 Hours. Sams Publishing, 2002. [21] S. Parker, Shell Scripting: Expert Recipes for Linux, Bash and more. John Wiley & Sons, 2011. [22] C. F. A. Johnson, Shell Scripting Recipes: A Problem Solution Approach. Dreamtech Press, 2007. [23] A. Verma, Unix and Shell Programming. Laxmi Publications, 2006. [24] B. A. Forouzan and R. F. Gilberg, UNIX and Shell Programming: A Textbook. Brooks/Cole-Thomson Learning, 2003. [25] Y. P. Kanetkar, Unix Shell Programming. BPB Publications, 2002. [26] T. Sanchez-Clark, Unix Shell Scripting Interview Questions, Answers, and Explanations: Unix Shell Certification Review. Equity Press, 2007. [27] D. Taylor, Wicked Cool Shell Scripts: 101 Scripts for Linux, Mac OS X, and Unix Systems. No Starch Press, 2004.

Echo Command echo command is used to display text or value of variable. echo [options] [string, variables...] Options -n Do not output the trailing new line. -e Enable interpretation of the following backslash escaped characters in the strings: \b backspace \c suppress trailing new line \n new line \t horizontal tab \\ backslash \r carriage return For e.g. $ echo -e "An apple a day \n keeps doctor \t\taway" User Defined Variables The user defined variables (UDV) can be defined and assigned values using the following syntax : variable_name=value Here, value is assigned to the variable with variable_name. The following are few valid syntax : no=10 my_age=45 vehicle=car vehicle= vehicle= readonly no=10 #null value #null value #variable no cannot be modified Few invalid syntax : no =10 no = 10

no= 10 10=no Splitting Long Commands Over Multiple Lines Long commands that cannot be accommodated in a single line can be split across multiple lines. For instance a command to copy file from /var/ftp/pub/userdata/applications/file.txt from server1.mylinux.com to the directory /var/ftp/pub/userdata/applications/ directory of server2.mylinux.com will be like: scp xyz@server1.mylinux.com: /var/ftp/pub/userdata/applications/file.txt xyz@server2.mylinux.com:/var/ftp/pub/userdata/applications/ The above command can be split within the script using concatenation operator (\). So the large command spanning several lines can be made more readable. The concatenation operator applied to the above command looks like: scp xyz@server1.mylinux.com:\ /var/ftp/pub/userdata/applications/file.txt\ xyz@server2.mylinux.com:\ /var/ftp/pub/userdata/applications/ Putting Multiple Commands on a Single Line Multiple commands can be grouped together in a single line using the semicolon (;) operator. The following commands will all execute even if one of the preceding command fails: $ cat file1 ; cat file2 ; cat file3 However, if we want to abort subsequent commands if any one command fails, we can use the and (&&) operator as follows: $ cat file1 && cat file2 && cat file3 We can use the or ( ) operator which ensures that if the first command fails, the second one will never be executed. $ cat file1 cat file2 cat file3

Creating custom commands Shell scripts can be converted to user defined commands or custom commands. Suppose we have create a shell program that displays date in a given format along with the count of users. Let us assume the file is mydate. We can create our own command mydate by making this script executable and placing it in one of the directories pointed by the PATH variable. For instance, we can place the mydate file in the /home/richard/bin directory so that the shell program becomes a command. Few Sample Scripts Script-1 #Script to reverse the name echo "Enter your name : " read nm echo "Reverse of your name is : " echo "$nm" rev Script-2 #Script to append content of first file into second file echo "First file : $1" echo "Second file : $2" cat $1 >> $2 Script-3 #Script to display line count of a file echo "File name : $1" cnt=`wc -l $1` echo "Count : $cnt" Script-4 #Using functions within shell scripts getdata() { echo "Enter your name : " read name echo "Enter your age : " read age } showdata() { echo "Your name: $name" echo "Your age: $age"

} getdata showdata Script-5 #store in file : demo.sh #execute as $demo.sh a b c d e f g