June 1, 1999Using The C-Shell1 Introduction to UNIX F. Using C Shell Features.

Slides:



Advertisements
Similar presentations
June 1, 1999Foreground/Background Processing1 Introduction to UNIX H. Foreground/Background Processing.
Advertisements

Introduction to UNIX. 2 Multitasking zForeground yCurrent Task yThe Command Running at the `$` Prompt zBackground yCommand Running Behind the Scenes yNot.
UNIX Chapter 12 Redirection and Piping Mr. Mohammad Smirat.
Introduction to UNIX Cornell University CS 316 – Fall 2006 Slides by Michael Siegenthaler.
CIS 118 – Intro to UNIX Shells 1. 2 What is a shell? Bourne shell – Developed by Steve Bourne at AT&T Korn shell – Developed by David Korn at AT&T C-shell.
Introduction to UNIX CSE 2031 Fall May 2015.
1 © 2001 John Urrutia. All rights reserved. Chapter 5 The Shell Overview.
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
1 UNIX essentials (hands-on) the directory tree running programs the shell (using the T-shell) → command line processing → special characters → command.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II CHAPTER 10: ADVANCED FILE PROCESSING.
Shell - Introduction & Commands Chapter III / Part II.
3 File Processing Mauro Jaskelioff. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash.
June 1, 1999Manipulating Files1 Introduction to UNIX E. Manipulating Files.
Introduction to UNIX Don Bahls user consultant (907)
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT I/O Redirection.
BIF703 stdin, stdout, stderr Redirection. stdin, stdout, stderr Recall the Unix philosophy “do one thing well”. Unix has over one thousand commands (utilities)
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP John Barr.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 8 Shell.
CS 2061 Shells Also known as: Unix Command Interpreter.
Shells. A program that is an interface between a user at a terminal and the computers resouces ▫The terminal may be real or an emulator The shell is.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Linux overview. Architecture Kernel File system Shell: Korn, Bourne, C, Bash X Windows: Motif, Open Look, X.OrgX.Org Desktop: Gnome, KDE,etc.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
June 1, 1999UNIX File System1 Introduction to UNIX D. UNIX File Structure.
1 UNIX essentials (hands-on) the directory tree running programs the shell → command line processing → special characters → command types → shell variables.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Lesson 2 1.Commands 2.Filename Substitution 3.I/O Redirection 4.Command Grouping 5.Shell Responisibilites Review of the Basics.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
I/O and Redirection. Standard I/O u Standard Output (stdout) –default place to which programs write u Standard Input (stdin) –default place from which.
Chapter Four I/O Redirection1 System Programming Shell Operators.
UNIX An Introduction. Brief History UNIX UNIX Created at Bell Labs, 1969 Created at Bell Labs, 1969 BSD during mid 70s BSD during mid 70s AT&T began offering.
June 1, 1999Customizing the UNIX Environment1 Introduction to UNIX G. Customizing the UNIX Environment.
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Week 9 - Nov 7, Week 9 Agenda I/O redirection I/O redirection pipe pipe tee tee.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Files and Directories in UNIX The first file in UNIX file system is “root” or “/”
Linux+ Guide to Linux Certification, Second Edition
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Introduction to Linux Workshop February 15, 2016.
1 © 2012 John Urrutia. All rights reserved. Chapter 09 The TC Shell.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Lesson 8-Specifying Instructions to the Shell. Overview An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
The UNIX Shell Learning Objectives:
Some Linux Commands.
Shell Environments.
CSE 303 Concepts and Tools for Software Development
John Carelli, Instructor Kutztown University
Unix : Introduction and Commands
Introduction to Computer Organization & Systems
Linux Shell Script Programming
Chapter 3 The UNIX Shells
Introduction to UNIX EECS July 2019.
Presentation transcript:

June 1, 1999Using The C-Shell1 Introduction to UNIX F. Using C Shell Features

June 1, 1999Using The C-Shell2 Using C Shell Features Performance Objectives 1. Use History to recall/repeat commands (history, !, !!) 2. Edit a command line using the replace function(^) 3. Edit a command line using the substitution method (:s) 4. Identify the concept of STDIN/STDOUT/STDERR 5. Redirect data Input and Output (>, <) 6. Append results of a command to existing files (>>, >>&) 7. Use Pipes to link command data (|) 8. Construct simple aliases (alias) 9. Recognize three basic error messages

June 1, 1999Using The C-Shell3 Shell Initialization and Termination Activities: n Reads.cshrc from home directory when new C shell started. n Reads.login when initiated as a login shell. n Reads.logout when shell terminated (if the login shell) n Operates in either interactive or non-interactive (batch) mode.

June 1, 1999Using The C-Shell4 Built-in Commands C Shell contains built-in commands: alias fg/bg echo history ignoreeof jobs kill noclobber noglob set setenv source stop suspend umask unalias The man page for csh is very long (about 100 screens). Use the man search feature (/keyword).

June 1, 1999Using The C-Shell5 The History Mechanism Command Line Editing Allows you to: è rerun any command in the history buffer, and è change/correct commands in the history buffer. To set up a history list: set history=15 (.cshrc) To display the last n commands. host% history 1 ls -l 2 cd ~ths 3 history

June 1, 1999Using The C-Shell6 Command Line Editing To make a new simpler command: host% alias hb history Note the following: host% cd unix/class/handouts/larn unix/class/handouts/larn: No such file or directory host% ^lar^lear^ cd unix/class/handouts/learn

June 1, 1999Using The C-Shell7 Command Line Editing A display of the history buffer reveals: host% history 2 cd ~ths 3 history 4 cd unix/class/handouts/larn 5 cd unix/class/handouts/learn 6 history To recall a previous command: host% !cd host% !5

June 1, 1999Using The C-Shell8 Command Line Editing You can list the last n commands from the history buffer: host% history 6 4 cd unix/class/handouts/larn 5 cd unix/class/handouts/learn 6 history 7 cat /home/ths/class0/basics/history/congrats 8 cat /etc/motd 9 history To rerun the correct cd command - !5 or !cd

June 1, 1999Using The C-Shell9 Command Line Editing Substitution changes any previous command: host% !7:s/0/1 cat /home/ths/sunclass1/basics/history/congrats History list should be similar to the following: 7 cat /home/ths/sunclass0/basics/history/congrats 8 cat /home/ths/sunclass1/basics/history/congrats 9 history 10 cat /home/ths/sunclass1/basics/history/congrats 11 history

June 1, 1999Using The C-Shell10 Redirecting Input/Output The 3 UNIX standard files are, the terminal. n STDIN (keyboard) n STDOUT (display) n STDERR (display) To redirect output to another file, use: n Greater-than > symbol to redirect STDOUT n Less-than < symbol to redirect STDIN n Ampersand & symbol to redirect STDERR

June 1, 1999Using The C-Shell11 Redirecting Input/Output Examples: è host% cat filea > fileb (redirect creates fileb) è host% cat filec >> fileb (appends to fileb) è host% cat filed >& e.file (error msgs to e.file) è host% cat filex >>& e.file (append error to e.file) è host% mail -s “sub” address < file (get input from file)

June 1, 1999Using The C-Shell12 Use of Pipes - | Special symbol “|” command [options] | command [options] |... Problem: n How many processes are running on your machine? n The command ps -ax will show all processes on a machine.

June 1, 1999Using The C-Shell13 Using Pipes (Con’t) But you must count each line on the screen: ted% ps -ax PID TT STAT TIME COMMAND 0 ? D 2:16 swapper 1 ? IW 0:00 /sbin/init - 2 ? D 0:12 pagedaemon 55 ? IW 2:59 portmap 60 ? IW 0:00 ypbind 62 ? IW 0:00 keyserv 73 ? S 1:57 (biod) 74 ? S 1:57 (biod) 75 ? S 1:57 (biod) 76 ? S 1:56 (biod) 87 ? IW 0:03 syslogd 95 ? IW 0:00 rpc.statd 97 ? IW 0:00 rpc.lockd 101 ? IW 11:01 automount 104 ? S 0:41 screenblank 109 ? S 20:21 update 112 ? IW 0:03 cron

June 1, 1999Using The C-Shell14 Use of Pipes - | (Con’t) There are several solutions to this problem: n Solution 1 host% ps -ax > psfile host% wc -l psfile è Note the number of processes n Solution 2 host% ps -ax | wc -l è Note the number of processes n Why is there a difference of one process?

June 1, 1999Using The C-Shell15 Using Filters with Pipes Lists are often difficult to preview visually: host% ls -l produces a long list of all files. -rw-r--r-- 1 pam 880 Sep Aug.notes drwxr-xr-x 2 pam 512 Oct bin -rw-r--r-- 1 pam 129 Aug complex.f -rw pam 129 Jul mbox -rw-r--r-- 1 pam 429 Aug 16 14:18 outdis drwxr-xr-x 2 pam 512 Jan 22 11:07 remodel -rwxr-xr-x 1 pam 102 Jun 19 12:55 test.out

June 1, 1999Using The C-Shell16 Using Filters with Pipes - grep To search a file for a specified string: host% ls -l | grep Aug -rw-r--r-- 1 pam 129 Aug complex.f -rw-r--r-- 1 pam 4291 Aug 16 14:18 outdis -rw-r--r-- 1 pam 880 Sep Aug.notes To search a file for all but specified string: host% ls -l | grep -v Aug drwxr-xr-x 2 pam 512 Oct bin -rw pam 129 Jul mbox drwxr-xr-x 2 pam 512 Jan 22 11:07 remodel -rwxr-xr-x 1 pam 102 Jun 19 2:55 test.out

June 1, 1999Using The C-Shell17 Using Filters - pipes, grep & sort Consider the next example: host% ls -l | grep Aug | sort +4 -rw-r--r-- 1 pam 129 Aug complex.f drwxr-xr-x 2 pam 512 Aug bin -rw-r--r-- 1 pam 880 Sep Aug.notes -rw-r--r-- 1 pam 929 Aug 16 14:18 outdis -rwxr-xr-x 1 pam 972 Aug 19 12:55 test.out

June 1, 1999Using The C-Shell18 Constructing Simple Aliases Examine the following aliases: alias rm rm -i Full pathnames are preferred: n alias cp /bin/cp -I Enclose complex commands in “quotes” n alias ls "pwd; /bin/ls -sFC" CommandAlias nameCommand line

June 1, 1999Using The C-Shell19 More Complex Aliases Importing an argument: alias chklog 'grep \!* log.* | more' è host% chklog reg1 alias cnt 'grep -c \!* log.*' alias f 'finger Alias name ArgumentList of files

June 1, 1999Using The C-Shell20 End of Module Complete Using C Shell Function Exercises