Sams Teach Yourself Shell Programming in 24 Hours Index Table of Contents

Total Page:16

File Type:pdf, Size:1020Kb

Sams Teach Yourself Shell Programming in 24 Hours Index Table of Contents Sams Teach Yourself Shell Programming in 24 Hours Index Table of Contents Sams Teach Yourself Shell Programming in 24 Hours Copyright Introduction ● How This Book Is Organized ● Conventions Used in This Book ● About the Author ● Dedication ● Acknowledgments Part I Introduction to UNIX and Shell Tools Hour 1: Shell Basics ● What Is a Command? ● What Is the Shell? ● Summary ● Questions ● Terms Hour 2: Script Basics ● The UNIX System ● Shell Initialization ● Getting Help ● Summary ● Questions ● Terms Hour 3: Working with Files ● Listing Files ● Viewing the Content of a File ● Manipulating Files ● Summary ● Questions ● Terms Hour 4: Working With Directories ● The Directory Tree ● Switching Directories ● Listing Files and Directories ● Manipulating Directories ● Summary ● Questions Hour 5: Manipulating File Attributes ● File Types ● Owners, Groups, and Permissions ● Summary ● Questions Hour 6: Processes ● Starting a Process ● Listing Running Processes ● Killing a Process (kill Command) ● Parent and Child Processes ● Summary ● Questions ● Terms Part II Shell Programming Hour 7: Variables ● Defining Variables ● Unsetting Variables ● Environment Variables ● Summary ● Questions ● Terms Hour 8: Substitution ● Filename Substitution (Globbing) ● Variable Substitution ● Command and Arithmetic Substitution ● Summary ● Questions Hour 9: Quoting ● Quoting with Backslashes ● Using Single Quotes ● Using Double Quotes ● Quoting Rules and Situations ● Summary ● Questions ● Terms Hour 10: Flow Control ● The if Statement ● The case Statement ● Summary ● Questions Hour 11: Loops ● The while Loop ● The for and select Loops ● Loop Control ● Summary ● Questions ● Terms Hour 12: Parameters ● Special Variables ● Options and Arguments ● Option Parsing in Shell Scripts ● Conclusion ● Questions Hour 13: Input/Output ● Output ● Input ● File Descriptors ● Summary ● Questions ● Terms Hour 14: Functions ● Creating and Using Functions ● Sharing Data Between Functions, an Example ● Conclusion ● Questions Hour 15: Text Filters ● The head and tail Commands ● Using grep ● Counting Words ● Summary ● Questions Hour 16: Filtering Text Using Regular Expressions ● The Basics of awk and sed ● Using sed ● Summary ● Questions Hour 17: Filtering Text with awk ● What is awk? ● Using awk Features ● Summary ● Questions ● Terms Hour 18: Miscellaneous Tools ● The eval Command ● The : Command ● The type Command ● The sleep Command ● The find Command ● xargs ● The expr Command ● The bc Command ● remsh/rsh/rcmd/remote (Remote Shell) ● Summary ● Questions ● Terms Part III Advanced Topics Hour 19: Dealing with Signals ● How Are Signal Represented? ● Dealing with Signals ● Conclusion ● Questions Hour 20: Debugging ● Enabling Debugging ● Syntax Checking ● Shell Tracing ● Summary ● Questions Hour 21: Problem Solving with Functions ● Creating a Library of Functions ● Useful Functions ● Summary ● Questions ● Terms Hour 22: Problem Solving with Shell Scripts ● Moving Directories ● Maintaining an Address Book ● Summary ● Questions ● Terms Hour 23: Scripting for Portability ● Determining UNIX Versions ● Techniques for Increasing Portability ● Summary ● Questions ● Terms Hour 24: Shell Programming FAQs ● Shell and Command Questions ● Variable and Argument Questions ● File and Directory Questions ● Summary Part IV Appendixes Appendix A: Command Quick Reference ● Reserved Words and Built-in Shell Commands ● Conditional Expressions ● Arithmetic Expressions (Korn/Bash Only) ● Parameters and Variables ● Parameter Substitution ● Pattern Matching ● I/O ● Miscellaneous Command Summaries ● Regular Expression Wildcards ● Summary ● Questions Appendix B: Glossary Appendix C: Quiz Answers ● Chapter 1 ● Chapter 2 ● Chapter 3 ● Chapter 4 ● Chapter 5 ● Chapter 6 ● Chapter 7 ● Chapter 8 ● Chapter 9 ● Chapter 10 ● Chapter 11 ● Chapter 12 ● Chapter 13 ● Chapter 14 ● Chapter 15 ● Chapter 16 ● Chapter 17 ● Chapter 18 ● Chapter 19 ● Chapter 20 ● Chapter 21 ● Chapter 22 ● Chapter 23 ● Appendix A Index Sams Teach Yoursel Shell Programming in 24 Hours Index Table of Contents Sams Teach Yourself Shell Programming in 24 Hours Contents Index Copyright Previous Chapter Next Chapter Copyright Sams Teach Yourself Shell Programming in 24 Hours Copyright © 1999 by Sams Publishing All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. International Standard Book Number: 0-672-31481-9 Library of Congress Catalog Card Number: 98-89272 Printed in the United States of America First Printing: March 1999 01 00 99 4 3 2 1 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an "as is" basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the programs accompanying it. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Copyright Previous Chapter Next Chapter © Copyright Macmillan Computer Publishing. All rights reserved. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Introduction Previous Chapter Next Chapter Sections in this Chapter: How This Book Is Organized Dedication Conventions Used in This Book Acknowledgments About the Author Previous Section Next Section Introduction In recent years, the UNIX operating system has seen a huge boost in its popularity, especially with the emergence of Linux. For programmers and users of UNIX, this comes as no surprise: UNIX was designed to provide an environment that's powerful yet easy to use. One of the main strengths of UNIX is that it comes with a large collection of standard programs. These programs perform a wide variety of tasks from listing your files to reading email. Unlike other operating systems, one of the key features of UNIX is that these programs can be combined to perform complicated tasks and solve your problems. One of the most powerful standard programs available in UNIX is the shell. The shell is a program that provides you with a consistent and easy-to-use environment for executing programs in UNIX. If you have ever used a UNIX system, you have interacted with the shell. The main responsibility of the shell is to read the commands you type and then ask the UNIX kernel to perform these commands. In addition to this, the shell provides sophisticated programming constructs that enable you to make decisions, repeatedly execute commands, create functions, and store values in variables. This book concentrates on the standard UNIX shell called the Bourne shell. When Dennis Ritche and Ken Thompson were developing much of UNIX in the early 1970s, they used a very simple shell. The first real shell, written by Stephen Bourne, appeared in the mid 1970s. The original Bourne shell has changed slightly over the years; some features were added and others were removed, but its syntax and its resulting power have remained the same. The most attractive feature of the shell is that it enables you to create scripts. Scripts are files that contain a list of commands you want to run. Because every script is contained in a file and every file has a name, scripts enable you to combine existing programs to create completely new programs that solve your problems. This book teaches you how to create, execute, modify, and debug shell scripts quickly and easily. After you get used to writing scripts, you will find yourself solving more and more problems with them. How This Book Is Organized About the Examples I assume that you have some familiarity with UNIX and know how to log in, create and edit files, and work with files and directories to a limited extent. If you haven't used UNIX in a while or you aren't familiar with one of these topics, don't worry. The first part of this book reviews this material thoroughly. This book is divided into three parts: ● Part I is an introduction to UNIX, the shell, and some common tools. ● Part II covers programming using the shell. ● Part III covers advanced topics in shell programming. Part I consists of Chapters 1 through 6. The following material covered in the individual chapters: ● Chapter 1, "Shell Basics," discusses several important concepts related to the shell and describes the different versions of the shell. ● Chapter 2, "Script Basics," describes the process of creating and running a shell script. It also covers the login process and the different modes in which the shell executes. ● Chapters 3, "Working with Files," and 4, "Working with Directories," provide an overview of the commands used when working with files and directories. These chapters show you how to list the contents of a directory, view the contents of a file, and
Recommended publications
  • La Kornshell: Lenguaje De Programación Y Comando
    La KornShell: Lenguaje de Programación y Comando Una guía para programadores de Shell Scripts de Unix Jesús Alberto Vidal Cortés http://inicia.es/de/chube [email protected] www.kornshell.com Madrid, Agosto de 2001 Índice PARTE I: INTRODUCCIÓN......................................................................................................... 11 1. SOBRE EL LENGUAJE KORNSHELL ........................................................................................... 12 ¿Qué es una Shell?.............................................................................................................. 12 Beneficios del uso de ksh..................................................................................................... 13 Mejoras como Lenguaje de Comandos ................................................................................................................ 13 Mejoras como Lenguaje de Programación........................................................................................................... 14 Versiones a las que se aplica este manual............................................................................. 15 ¿Cómo obtener ksh?............................................................................................................ 16 2. NOTACIÓN UTILIZADA EN ESTE MANUAL..................................................................................... 18 General ............................................................................................................................... 18 Teclas sobre
    [Show full text]
  • Squeezing Water from Stone: Kornshell in 2019
    Squeezing Water from Stone: KornShell in 2019 Siteshwar Vashisht @SiteshwarV main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);} ● Winner of IOCCC (The International Obfuscated C Code Contest) one line entry in 1987. ● Termed as best one liner ever received. ● Written by David Korn. What this talk is about ? ● It’s about AT&T KornShell (ksh, not mksh or pdksh). ● Brief status update from new upstream maintainers (Kurtis Rader and Siteshwar Vashisht). ● No deep dive in the source code. ● It is slightly extended version of my talk from FOSDEM 2019 and All Systems Go! 2019. /whois situ ● Siteshwar Vashisht. ● Based in Brno, Czech Republic. ● Maintainer of bash and ksh at Red Hat. ● Previously involved with fish shell and Sailfish OS. ● Current upstream maintainer of ksh. What is KornShell ? ● Direct descendant of Bourne shell. ● Initial development based on original bourne shell. ● Roots back to late 70’s and early 80’s. Spot the bug! #!/bin/bash echo $'hello world' | while read foo do bar="$foo" done echo "bar: " "$bar" $bar is not available outside loop. Bash forks last command in a new process and $bar is lost. Advantages ● Superior language specification (Support for Discipline functions, namespaces, compound data type, enums etc.). ● Better POSIX compliance. ● Fastest POSIX shell. Show me the numbers! $ cat test.sh for ((i=0;i<10000;i++)) do foo=$(echo "bar baz") done $ time bash test.sh $ time zsh test.sh $ time ksh test.sh real 0m2.977s real 0m2.433s real 0m0.078s user 0m2.032s user 0m1.570s user 0m0.062s sys 0m1.167s sys 0m1.233s sys 0m0.015s A 20 year old bug State of ksh in 2017 ● Previous developers have left.
    [Show full text]
  • Common Desktop Environment: Desktop Kornshell User's Guide
    Common Desktop Environment: Desktop KornShell User’s Guide Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, CA 94303 U.S.A. Part No: 805-3917–10 October 1998 Copyright 1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California 94303-4900 U.S.A. All rights reserved. This product or document is protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or document may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Third-party software, including font technology, is copyrighted and licensed from Sun suppliers. Parts of the product may be derived from Berkeley BSD systems, licensed from the University of California. UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd. Sun, Sun Microsystems, the Sun logo, SunDocs, Java, the Java Coffee Cup logo, and Solaris are trademarks, registered trademarks, or service marks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc. The OPEN LOOK and SunTM Graphical User Interface was developed by Sun Microsystems, Inc. for its users and licensees. Sun acknowledges the pioneering efforts of Xerox in researching and developing the concept of visual or graphical user interfaces for the computer industry. Sun holds a non-exclusive license from Xerox to the Xerox Graphical User Interface, which license also covers Sun’s licensees who implement OPEN LOOK GUIs and otherwise comply with Sun’s written license agreements.
    [Show full text]
  • Squeezing Water from Stone: Kornshell in 2019
    Squeezing Water from Stone: KornShell in 2019 Siteshwar Vashisht @SiteshwarV main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);} ● Winner of IOCCC (The International Obfuscated C Code Contest) one line entry in 1987. ● Termed as best one liner ever received. ● Written by David Korn. What this talk is about ? ● It’s about AT&T KornShell (ksh, not mksh or pdksh). ● Brief status update from new upstream maintainers (Kurtis Rader and Siteshwar Vashisht). ● No deep dive in the source code. ● It is slightly extended version of my talk from FOSDEM 2019. /whois situ ● Siteshwar Vashisht. ● Based in Brno, Czech Republic. ● Maintainer of bash and ksh at Red Hat. ● Previously involved with fish shell and Sailfish OS. ● Current upstream maintainer of ksh. What is KornShell ? ● Direct descendant of Bourne shell. ● Initial development based on original bourne shell. ● Roots back to late 70’s and early 80’s. Spot the bug! #!/bin/bash echo $'hello world' | while read foo do bar="$foo" done echo "bar: " "$bar" $bar is not available outside loop. Bash forks last command in a new process and $bar is lost. Advantages ● Superior language specification (Support for Discipline functions, namespaces, compound data type, enums etc.). ● Better POSIX compliance. ● Fastest POSIX shell. Show me the numbers! $ cat test.sh for ((i=0;i<10000;i++)) do foo=$(echo "bar baz") done $ time bash test.sh $ time zsh test.sh $ time ksh test.sh real 0m2.977s real 0m2.433s real 0m0.078s user 0m2.032s user 0m1.570s user 0m0.062s sys 0m1.167s sys 0m1.233s sys 0m0.015s A 20 year old bug State of ksh in 2017 ● Previous developers have left.
    [Show full text]
  • Squeezing Water from Stone: Kornshell in 2019
    Squeezing Water from Stone: KornShell in 2019 main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);} ●Winner of IOCCC (The International Obfuscated C Code Contest) one line entry in 1987. ●Termed as best one liner ever received. ●Written by David Korn. What this talk is about ? ●It’s about AT&T KornShell (and not mksh/pdksh). ●Brief status update from new upstream maintainers (Kurtis Rader and Siteshwar Vashisht). ●No deep dive in the source code. /whois situ ●Siteshwar Vashisht. ●Based in Brno, Czech Republic. ●Maintainer of bash and ksh at Red Hat. ●Previously involved with fish shell and Sailfish OS. ●Current upstream maintainer of ksh. What is KornShell ? ●Direct descendant of Bourne shell. ●Initial development based on original bourne shell. ●Roots back to late 70s/early 80s. Advantages ●Superior language specification (Support for Discipline functions, namespaces, compound data type, enums etc.). ●Better POSIX compliance. ●Fastest POSIX shell. A 20 year old bug State of ksh in 2017 ●Previous developers have left. ●Codebase has origins going back to the 80s. ●Old Tooling. ●No revision control history. ●Almost no comments in the source code. ●Spaghetti code. ●Bad test coverage. ●Lots of old bugs. ●And ... How to maintain the unmaintainable ? One of my most productive days was throwing away 1,000 lines of code - Ken Thompson We threw away more than 500,000 lines of code. Lines of code (ksh93v-) Lines of code (current) What did we drop ? ●Support for non-POSIX operating systems. ●Reimplementation of POSIX functions. ●Entire subsystems like the AST vmalloc and locale. ●Lots of code that was not used by ksh.
    [Show full text]
  • Mastering EOS Release 1.0
    Mastering EOS Release 1.0 Sean Fisk and Ira Woodring May 12, 2015 CONTENTS 1 Introduction 3 1.1 Physical Access (Keycards) ....................................... 3 1.2 Computer Access (Credentials) ..................................... 3 2 Rules and Procedures 5 2.1 Disk Space ................................................ 5 2.2 Copyrighted Material ........................................... 5 2.3 Food and Drink .............................................. 6 2.4 Overnight Parking ............................................ 6 2.5 Living in the Lab ............................................. 6 2.6 Malicious Activity ............................................ 6 2.7 Games .................................................. 6 3 Using the Command Line 7 3.1 Command-Line Basics .......................................... 7 3.2 Available Shells ............................................. 7 3.3 Interactive Shell Use ........................................... 10 3.4 Shell Scripting .............................................. 24 4 Remote Access (SSH/VNC) 27 4.1 Inter-EOS SSH .............................................. 27 4.2 Microsoft Windows ........................................... 28 4.3 Mac OS X ................................................ 36 4.4 GNU/Linux ................................................ 49 5 User-level Software Installation 65 5.1 The Standard Hierarchy ......................................... 65 5.2 Manual Installation ............................................ 66 5.3 Linuxbrew ...............................................
    [Show full text]
  • All MKS Toolkit Commands
    All MKS Toolkit Commands The various MKS Toolkit products include different subsets of commands and utilities. Click the product link on the right to view the product-specific command lists. * denotes a Shell built-in † denotes a groff command ‡ denotes a command which requires an X Server § denotes a command that applies only to N uTCRACKER Platform applications ¥ denotes a command whose binary and source code can be found in the Samples directory of the CD distribution or in the Resource Kit and is an example of porting UNIX source code with MKS Toolkit for Enterprise Developers . * — execute KornShell script in current environment : * — expand arguments and do nothing, successfully [ * — test for condition [[ * — test for condition 64decode.exe — decode a file using base64 64encode.exe — encode a file using base64 a2p.exe — awk to perl translator addftinfo.exe †¥ — add information to troff font files for use with groff afmtodit.exe †¥ — create font files fo ruse with groff -Tps alias * — display or create command aliases appc.ksh — arbitrary precision programmable calculator AppPkgWz.exe — Packaging Wizard for deploying MKS Toolkit ported applications. appres.exe ‡ — list X application resource database ar.exe — create and maintain library archives asa.exe — interpret ASA/FORTRAN carriage control assoc.ksh — set file extension association at.exe — execute commands at a later time atobm.exe ‡ — bitmap editor and converter for the X Window System autoload * — display or modify Shell functions autorun.ksh — specify programs to run on bootup
    [Show full text]
  • Korn-Shell-Programmierung Und Zeichenkettenverarbeitung Unter Unix/Linux
    Korn-Shell-Programmierung und Zeichenkettenverarbeitung unter Unix/Linux FWPF WS 2005/2006 -- Februar 02.2006 © Th. Fuhr Korn-Shell-Programmierung und Zeichenkettenverarbeitung 1 unter Unix/Linux Überblick • Einstieg Korn-Shell – Konfiguration, History-Funktion, Kommandozeilen-Editing – Kommandos und Kommandoverknüpfung – Kommandosubstitution – Reguläre Ausdrücke – Dateinamenexpansion – Quoting – Debugging • Unix-Tools (Teil 1) – Auflistung von Dateinamen – Ausgabe von Zeilen genannter Dateien – Ausgabe von manipulierten Zeileninhalten genannter Dateien • Korn-Shell (Fortsetzung) 02.2006 © Th. Fuhr Korn-Shell-Programmierung und Zeichenkettenverarbeitung 2 unter Unix/Linux Überblick • Korn-Shell-Skripten – Skriptform & -aufruf – Skript I/O: print – Shellvariablen (Grundlagen), Parametersubstitution, Quoting – Datenübergabe – Datenrückgabe – Variablenmanipulation – Bedingte Verzweigung & Bedingungstest – Schleifen – Arrays & Positionsparameter – Variablenattribute – Ein-Ausgabe-Umlenkung – Benutzermenues – Optionsverarbeitung – Funktionen – zweifache Kommandozeilenverarbeitung – Zeitmessung 02.2006 © Th. Fuhr Korn-Shell-Programmierung und Zeichenkettenverarbeitung 3 unter Unix/Linux Überblick • Unix-Tools (Teil 2) – fgrep, grep, egrep – sed 02.2006 © Th. Fuhr Korn-Shell-Programmierung und Zeichenkettenverarbeitung 4 unter Unix/Linux Literatur • Linux-Unix-Shells ksh (sh, bash, csh, tcsh) Helmut Herold Bsp. als tgz-File-Download Addison-Wesley, 1999 • Linux-Unix-Kurzreferenz ksh (sh, bash, csh, tcsh) Helmut Herold Unix/Linux-Tools Addison-Wesley,
    [Show full text]
  • MKS Toolkit for Developers
    MKS Toolkit for Developers A mixed computing environment, . Efficiently and cost-effectively Issues of interoperability also by consequence, demands a deploy UNIX trained affect development for the Web, consistent set of commands and personnel to new platforms. as companies intermingle UNIX utilities. A significant number of and Windows Web servers. MKS . Ease the interoperability corporate developers are fluent in Toolkit for Developers has high- challenge by seamlessly the UNIX environment, so utilities performance text utilities and sharing programming scripts, which are UNIX-based yet specialized Web development files and data between UNIX operate in Windows, can instantly tools that are ideal for and Windows. leverage the skills of UNIX trained maintaining HTML and all aspects people onto new platforms. of Web sites. Scripting languages and familiar MKS Toolkit for Developers also tools ensure that the valuable accelerates personal performance Lower TCO through Enterprise programming expertise of UNIX on the Windows platform by Interoperability developers, and the power of including Windows specific tools Instead of choosing between commands such as the KornShell, to: Windows and UNIX, most MIS CShell, awk, and Perl, does not . Unify and automate software organizations are opting for a mix have to be compromised because builds across UNIX and of the two operating systems, of the introduction of Windows. Windows. with many larger organizations Such utilities also reduce the using Windows as an add-on to immediate need for cross- . Connect to remote UNIX and their enterprise-wide backroom platform training. Windows machines. strategy. In order to decrease the total cost of ownership (TCO) of Global 2000 customers use the .
    [Show full text]
  • Unix Scripts and Job Scheduling Overview Running a Shell Script
    Unix Scripts and Job Scheduling Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh [email protected] http://www.sis.pitt.edu/~spring Overview Ü Shell Scripts Shell script basics Variables in shell scripts Kornshell arithmetic Commands for scripts Flow control, tests, and expressions Making Scripts Friendlier Functions Pipes and Shell Scripts Scripts with awk and/or sed Ü Job Scheduling bg and at cron Running a Shell Script Ü First three forms spawn a new process, so new variable values are not left when you return sh < filename – wheresh is the name of a shell – does not allow arguments sh filename filename – Assumes directory in path – Assumeschmod +x filename . filename – Does not spawn a new shell. – Changes to system variables impact the current shell Ü you may exit a shell script by Getting to the last line Encountering an exit command Executing a command that results in an error condition that causes an exit. 1 Structure of a Shell Script Ü Basic structure #! Program to execute script # comment Commands and structures Ü Line continuation | at the end of the line is an assumed continuation \ at the end of a line is an explicit continuation Ü # in a shell script indicates a comment to \n Ü Back quotes in command cause immediate execution and substitution Debugging a script Ü Use the command set –x within a script Ü You can also activate the following set options -n read commands before executing them – for testing scripts -u make it an error to reference a non existing file -v print input as it is read - disable the –x and –v commands Ü Set the variable PS4 to some value that will help – e.g.
    [Show full text]
  • Section 2 LINUX.Pdf
    WINDOWS AND LINUX LAB SECTION 2 LINUX Structure Page Nos. 2.0 Introduction 14 2.1 Objectives 14 2.2 History of UNIX and LINUX 15 2.3 Features of LINUX 16 2.4 Kernel and the Shell 17 2.4.1 Commands and Processes 2.4.2 LINUX File System 2.4.3 Wild Card Characters 2.4.4 Syntax of LINUX Commands 2.4.5 Getting Help 2.5 LINUX Commands 22 2.6 Description of Commonly Used LINUX Commands 26 2.7 Introduction to Shell Programming 34 2.7.1 LINUX Shells 2.7.2 Deciding on a Shell 2.8 Bourne Again Shell Programming 36 2.9 General Guidelines 42 2.10 Practical Sessions 44 2.11 Summary 48 2.12 Further Readings 48 2.13 Website References 48 2.14 Virtual Labs / IDEs / Online Lab Resources 49 2.0 INTRODUCTION This is the lab course, wherein you will have the hands on experience. You have studied the course material (MCS-203 Operating Systems). A list of tasks to be performed (sessionwise) on LINUX is given along with some programming problems towards the end. Please go through the general guidelines and the program documentation guidelines carefully. 2.1 OBJECTIVES After completing this lab course you will be able to: Apply the concepts that have been covered in the theory course; Understand the features LINUX; Gain experience in overall command line interface as well as GUI; Make use of different functions/operations of LINUX; Work with the utilities in LINUX; Write simple shell programs and simulate the functionalities for the given tasks; To understand and make effective use Shell scripting language Bash to solve Problems.
    [Show full text]
  • User Commands Ksh ( 1 ) Ksh, Rksh – Kornshell, a Standard/Restricted
    User Commands ksh ( 1 ) NAME ksh, rksh ± KornShell, a standard/restricted command and programming language SYNOPSIS /usr/bin/ksh [ ± abCefhikmnoprstuvx ] [ ± o option ] ... [ arg ... ] /usr/bin/ksh -c [ ± abCefhikmnoprstuvx ] [ ± o option ] ... command_string [ command_name [ arg ... ] ] /usr/xpg4/bin/sh [ ± abCefhikmnoprstuvx ] [ ± o option ] ... [ arg ... ] /usr/xpg4/bin/sh -c [ ± abCefhikmnoprstuvx ] [ ± o option ] ... command_string [ command_name [ arg ... ] ] /usr/bin/rksh [ ± abCefhikmnoprstuvx ] [ ± o option ] ... [ arg ... ] /usr/bin/rksh -c [ ± abCefhikmnoprstuvx ] [ ± o option ] ... command_string [ command_name [ arg ... ] ] DESCRIPTION /usr/xpg4/bin/sh is identical to /usr/bin/ksh, a command and programming language that executes com- mands read from a terminal or a ®le. rksh is a restricted version of the command interpreter ksh; it is used to set up login names and execution environments whose capabilities are more controlled than those of the standard shell. See Invocation below for the meaning of arguments to the shell. De®nitions A metacharacter is one of the following characters: ; & ( ) < > NEWLINE SPACE TAB A blank is a TAB or a SPACE. An identi®er is a sequence of letters, digits, or underscores starting with a letter or underscore. Identi®ers are used as names for functions and variables. A word is a sequence of characters separated by one or more non-quoted metacharacters. A command is a sequence of characters in the syntax of the shell language. The shell reads each com- mand and carries out the desired action either directly or by invoking separate utilities. A special- command is a command that is carried out by the shell without creating a separate process. Except for documented side effects, most special commands can be implemented as separate utilities.
    [Show full text]