Module # 14 References:

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

UNIX Programming Laboratory. Subject Code: 10MCA17

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

Conditional Control Structures. Dr.T.Logeswari

LOG ON TO LINUX AND LOG OFF

COMP 4/6262: Programming UNIX

INd_rasN SOME SHELL SCRIPTING PROGRAMS. 1. Write a shell script to check whether the name passed as first argument is the name of a file or directory.

Unix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP

Name: Tej. D. Shah Subject:CC-304 Linux Uni. Practical programme College :L.J. College Of Computer Application. Questions:

2. UDP Client, UDP Server

CS214 Advanced UNIX Lecture 4

Bourne Shell Reference

Prof. Navrati Saxena TA: R. Sachan Bharat Jyoti Ranjan

Shell Programming. Introduction to Linux. Peter Ruprecht Research CU Boulder

example: name1=jan name2=mike export name1 In this example, name1 is an environmental variable while name2 is a local variable.

UNIX 및실습. 13 장보충 bash(2)

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

Shell programming. Introduction to Operating Systems

Shells and Shell Programming

Shells and Shell Programming

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

28-Nov CSCI 2132 Software Development Lecture 33: Shell Scripting. 26 Shell Scripting. Faculty of Computer Science, Dalhousie University

Lecture 02 The Shell and Shell Scripting

UNIX Shell Scripts. What Is a Shell? The Bourne Shell. Executable Files. Executable Files: Example. Executable Files (cont.) CSE 2031 Fall 2012

Basic Linux (Bash) Commands

CSC 2500: Unix Lab Fall 2016

bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017

Lab #12: Shell Scripting

Computer Systems and Architecture

Scripting. More Shell Scripts. Adapted from Practical Unix and Programming Hunter College

Useful Unix Commands Cheat Sheet

EECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018

Linux Shell Script. J. K. Mandal

Computer Systems and Architecture

Shells & Shell Programming (Part B)

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

bash Tests and Looping Administrative Shell Scripting COMP2101 Fall 2017

Shell Script Example. Here is a hello world shell script: $ ls -l -rwxr-xr-x 1 horner 48 Feb 19 11:50 hello* $ cat hello #!/bin/sh

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

Linux & Shell Programming 2014

Shell Control Structures

b. Write a shell script to find smallest of three numbers that are read from keyboard. Page 1 07MCA28 Unix Lab Manual:

Linux shell programming for Raspberry Pi Users - 2

LING 408/508: Computational Techniques for Linguists. Lecture 5

Shell Programming (Part 2)

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

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

Assignment clarifications

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 2

Mastering UNIX Shell Scripting

Bash scripting basics

Course Contents/Syllabus: Weightage (%) Module I: Introduction to operating system: 15

INTRODUCTION TO UNIX

Bash shell programming Part II Control statements

Linux 系统介绍 (III) 袁华

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

OPERATING SYSTEMS LAB LAB # 6. I/O Redirection and Shell Programming. Shell Programming( I/O Redirection and if-else Statement)

Linux Shell Scripting. Linux System Administration COMP2018 Summer 2017

Vi & Shell Scripting

Preview. Review. The test, or [, command. Conditions. The test, or [, command (String Comparison) The test, or [, command (String Comparison) 2/5/2019

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

BASH Programming Introduction

bash Execution Control COMP2101 Winter 2019

SHELL SCRIPT BASIC. UNIX Programming 2014 Fall by Euiseong Seo

/smlcodes /smlcodes /smlcodes. Shell Scripting TUTORIAL. Small Codes. Programming Simplified. A SmlCodes.Com Small presentation

UNIX shell scripting

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

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

EECS2301. Lab 1 Winter 2016

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

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

There are some string operators that can be used in the test statement to perform string comparison.

Name of chapter & details

Processes and Shells

SHELL SCRIPT BASIC. UNIX Programming 2015 Fall by Euiseong Seo

Shell Start-up and Configuration Files

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

Practice 5 Batch & Shell Programming

DISPLAYING A MESSAGE FOR TRAFFIC SIGNAL

Introduction to Linux (and the terminal)

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

Filemaker Pro Design & Scripting For Dummies Free Download PDF

Shell Programming (ch 10)

Lec 1 add-on: Linux Intro

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

Lab 4: Shell scripting

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

Linux & Shell Programming 2014

On successful completion of the course, the students will be able to attain CO: Experiment linked. 2 to 4. 5 to 8. 9 to 12.

SEMESTER 6. BCA602: Software Engineering BCA601: WEB TECHNOLOGY. Book of study : Reference 1.HTML Black Book, Steven Holzner, Dreamtech Publishers

Korn Shell Unix And Linux Programming Manual Third Edition Pdf

Chapter 5 The Bourne Shell

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

System Programming. Session 6 Shell Scripting

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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

Introduction to Linux

Operating Systems. Lab Manual. Compiled by: Mr. Mohammed Al-Qadhi Computer Science Department

Linux shell scripting Getting started *

CS Unix Tools & Scripting

Transcription:

Module # 14 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 Certication 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.

Few Shell Scripts for Reference: Script-1: String Processing echo "STRING MANIPULATION PROGRAM" echo "1. COMPARE STRING" echo "2. JOINT TWO STRING" echo "3. LENGTH OF STRING" echo "4. OCCOURANCE OF CHARACTER" echo "5. OCCOURANCE OF WORD" echo "6. REVERSE STRING" echo "ENTER CHOICE:" read ch case $ch in 1) echo "ENTER FIRST STRING:" read str1 echo "ENTER SECOND STRING:" read str2 len1=`echo $str1 wc -c` len2=`echo $str2 wc -c` if [ $len1 -eq $len2 ];then echo "BOTH STRINGS ARE OF SAME LENGTH" elif [ $len1 -gt $len2 ];then echo "$str1 is greater than $str2" echo "$str2 is greater than $str1" 2) echo "ENTER FIRST STRING:" read str1 echo "ENTER SECOND STRING:" read str2 str1="$str1$str2" echo "COMBINED STRING : $str1" 3) echo "ENTER STRING:" read str len=`echo $str wc -c` echo "Length of string is $len" 4) echo "ENTER STRING:" read str echo "ENTER character of word to search:" read search len=`echo $str wc -c` i=1 while [ $i -lt $len ]

do ch=`echo $str cut -c $i` echo $ch i=`expr $i + 1` 5) echo "NOT THERE" 6) echo "ENTER STRING:" read str echo "REVERSE STRING IS : "`echo $str rev` *) echo "ENTER PROPER CHOICE" echo "NOT THERE" esac Script-2: Display of Greeting Message HH=`date +%H` time=`date +"%S %p"` if [ $HH -ge 12 ];then HH=`expr $HH % 12` if [ $HH -lt 5 ];then msg="good AFTERNOON" elif [ $HH -ge 5 ] && [ $HH -lt 9 ];then msg="good EVENING" msg="good NIGHT" echo "$msg,current TIME $HH:$time" exit 1 if [ $HH -lt 5 ];then msg="good NIGHT" msg="good MORNING" echo "$msg,current TIME $HH:$time" exit 1 Script-3: Display of All words of a le in ascending order echo "Ascending order of word in File" echo " ===============================" echo "Enter File Name " read lename echo "\n\n\t\t\t Main File "

echo "\t\t\t =========" echo `cat $lename` for i in `cat $lename` do echo $i >> temple.txt `sort temple.txt>$lename` echo "\n\n\t\t\tsorted Word in File " echo "\t\t\t ===================\n" echo `cat $lename` rm temple.txt Script-4: Delete Zero sized le from current directory `echo ls`>lelist for lename in `cat lelist` do if [! -d $lename ];then size=`ls -s $lename` size=`echo $size cut -d " " -f 1` if [ $size -eq 0 ];then echo "Want to Remove $lename:" rm -i $lename Script-5: Calculate Gross Salary from basic, DA=20% and HRA=10% echo " GROSS SALARY CALCULATOR" echo " =======================" echo "ENTER BASIC SALARY:" read basic hra=`expr 10 \* $basic / 100` da=`expr 20 \* $basic / 100` gs=`expr $basic + $hra + $da` echo "GROSS SALARY IS $gs" Script-6: A shell script illustrating the use of the case construct. echo MENU\n 1. Long List of les\n2. Today s Date\n3. Process status\n4.users of the System\n5. Display the present working directory and \n 6. Quit to Unix\nEnter your option : \c read choice case $choice in 1) Is I 2) date 3) ps -ef

esac 4) who -Hu 5) pwd 6) exit *) echo Invalid Choice exit Script-7: Sample for loop for x in 1 3 5 7 # four members in the list do echo The value of x is $x Script-8: A shell script illustrating the use of the break and continue. ans=y while [ $ans = y ] echo MENU\n 1. List of les\n2. Today s Date\n3. Process Status\n4. Users of the System\n5. present working directory\n6. Quit to Unix\n Enter your option : \c read choice case $choice in l) ls I 2) date 3) ps 4) who 5) pwd 6) break *) echo Invalid Choice continue esac Script-9: A shell script to calculate area using bc and scale

$cat triangle_area.sh echo \n Enter a value for base : \c read base echo \n Enter a value for height \c read height area= echo scale=2 \n 1/2*$base*$height bc echo The area of the tri4angle is $area Script-10: A shell script that uses bc $cat degree_conv.sh echo \n Enter a Fahrenheit value : \c read fahr cel= echo scale=2 \n 5/9*($fahr_32) I bc echo The equivalent degree Celsius = $cel