Shell scripting overview.ppt - Shell Scripting Overview 1 Common Utilities for Managing files and directories \u2022 \u2022 \u2022 \u2022 \u2022 \u2022 \u2022 \u2022 \u2022 \u2022

Shell scripting overview.ppt - Shell Scripting Overview 1...

This preview shows page 1 - 15 out of 65 pages.

Shell Scripting: Overview 1
Image of page 1
Common Utilities for Managing files and directories pwd print process working dir ed, vi, emacs create/edit files ls list contents of directory rm remove file mv rename file cp copy a file touch create an empty file or update mkdir and rmdir create and remove dir wc counts the words in a file file determine file contents du directory usage 2
Image of page 2
Standard in/out/err The first three entries in the file descriptor table are special by convention: cat Entry 0 is for input Entry 1 is for output Entry 2 is for error messages 3
Image of page 3
Devices Besides files, input and output can go from/to various hardware devices. UNIX innovation : Treat these just like files! /dev/tty, /dev/lpr, /dev/modem By default, standard in/out/err opened with /dev/tty Programs don't need to distinguish between files and devices 4
Image of page 4
What is a shell? The user interface to the operating system Functionality: Execute other programs Manage files Manage processes Full programming language A program like any other This is why there are so many shells 5
Image of page 5
Shell History There are many choices for shells Shell features evolved as UNIX grew 6
Image of page 6
Most Commonly Used Shells /bin/csh C shell /bin/tcsh Enhanced C Shell /bin/sh The Bourne Shell / POSIX shell /bin/ksh Korn shell /bin/bash Korn shell clone, from GNU 7
Image of page 7
Ways to use the shell Interactively When you log in, you interactively use the shell Scripting A set of shell commands that constitute an executable program 8
Image of page 8
UNIX Programs Means of input : Program arguments [control information] Environment variables [state information] Standard input [data] Means of output : Return status code [control information] Standard out [data] Standard error [error messages] 9
Image of page 9
Shell Scripts A shell script is a regular text file that contains shell or UNIX commands Before running it, it must have execute permission: chmod +x filename A script can be invoked as: sh filename [ arg … ] sh < filename [ args … ] filename [ arg …] 10
Image of page 10
Shell Scripts When a script is run, the kernel determines which shell it is written for by examining the first line of the script If 1 st line starts with #! pathname-of-shell , then it invokes pathname and sends the script as an argument to be interpreted e.g. #!/bin/bash If #! is not specified, the current shell assumes it is a script in its own language leads to problems 11
Image of page 11
Simple Example #!/bin/sh echo Hello World 12
Image of page 12
The Bourne Shell Slight differences on various systems Evolved into standardized POSIX shell Scripts will also run with ksh , bash Influenced by ALGOL 13
Image of page 13
Simple Commands simple command : sequence of non blanks arguments separated by blanks or tabs.
Image of page 14
Image of page 15

You've reached the end of your free preview.

Want to read all 65 pages?

  • Fall '19

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes