CIRC Summer School 2016 Baowei Liu

Slides:



Advertisements
Similar presentations
CST8177 sed The Stream Editor. The original editor for Unix was called ed, short for editor. By today's standards, ed was very primitive. Soon, sed was.
Advertisements

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.
EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
7 Searching and Regular Expressions (Regex) Mauro Jaskelioff.
2006-Jan-231 Shell Scripts Jacob Morzinski
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Guide To UNIX Using Linux Third Edition
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Console and File I/O - Basics Rudra Dutta CSC Spring 2007, Section 001.
Filters using Regular Expressions grep: Searching a Pattern.
Shell Script Examples.
Chapter 4: UNIX File Processing Input and Output.
Linux Tools. Tar tar – (Tape Archive). This is a tool for archiving files and directory hierarchies. tar output can be sent to stdout using the – file.
3 File Processing Mauro Jaskelioff. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash.
Overview of the grep Command Alex Dukhovny CS 265 Spring 2011.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Guide To UNIX Using Linux Fourth Edition
1 Shell Programming – Extra Slides. 2 Counting the number of lines in a file #!/bin/sh #countLines1 filename=$1#Should check if arguments are given count=0.
Unix Talk #2 (sed). 2 You have learned…  Regular expressions, grep, & egrep  grep & egrep are tools used to search for text in a file  AWK -- powerful.
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.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Module 6 – Redirections, Pipes and Power Tools.. STDin 0 STDout 1 STDerr 2 Redirections.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
CSC 352– Unix Programming, Spring 2015 April 28 A few final commands.
Pipes and Filters Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Lesson 2 1.Commands 2.Filename Substitution 3.I/O Redirection 4.Command Grouping 5.Shell Responisibilites Review of the Basics.
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.
I/O Redirection and Regular Expressions February 9 th, 2004 Class Meeting 4.
Introduction to sed. Sed : a “S tream ED itor ” What is Sed ?  A “non-interactive” text editor that is called from the unix command line.  Input text.
Chapter Four I/O Redirection1 System Programming Shell Operators.
40 Years and Still Rocking the Terminal!
I/O Redirection & Regular Expressions CS 2204 Class meeting 4 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Week 9 - Nov 7, Week 9 Agenda I/O redirection I/O redirection pipe pipe tee tee.
CSCI 330 UNIX and Network Programming Unit IV Shell, Part 2.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Bash Shell. What is Shell? The shell is a command interpreter. It is the layer between the operating system kernel and the user.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2014 Lecture 3 – I/O Redirection, Shell Scripts.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
CSC 352– Unix Programming, Fall 2011 November 8, 2011, Week 11, a useful subset of regular expressions, grep and sed, parts of Chapter 11.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Linux Administration Working with the BASH Shell.
Filters and Utilities. Notes: This is a simple overview of the filtering capability Some of these commands are very powerful ▫Only showing some of the.
Introduction to the bash Shell (Bourne-Again SHell)
Bash Scripting CIRC Summer School 2016 Baowei Liu CIRC Summer School 2016 Baowei Liu.
CIRC Winter Boot Camp 2017 Baowei Liu
CSC 352– Unix Programming, Spring 2016
Shell Features CSCI N321 – System and Network Administration
Looking for Patterns - Finding them with Regular Expressions
CIRC Summer School 2017 Baowei Liu
CST8177 sed The Stream Editor.
CIRC Winter Boot Camp 2017 Baowei Liu
CSE 374 Programming Concepts & Tools
CIRC Summer School 2017 Baowei Liu
CSE 303 Concepts and Tools for Software Development
Tutorial of Unix Command & shell scriptS 5027
CSC 352– Unix Programming, Fall 2012
Tutorial of Unix Command & shell scriptS 5027
CSC 352– Unix Programming, Spring 2016
Tutorial of Unix Command & shell scriptS 5027
Unix Talk #2 (sed).
Chapter Four UNIX File Processing.
CSC 4630 Meeting 4 January 29, 2007.
LPI Linux Certification
Presentation transcript:

CIRC Summer School 2016 Baowei Liu Bash Scripting CIRC Summer School 2016 Baowei Liu

Day 3 Examples ssh to bluehive cd your directory for this class ./shareFiles.sh Day3

Stdin, stdout and stderr File descriptor(FD): a handle to access a file Stdin: standard input stream (e.g. keyboard) –FD:0 Stdout: standard output stream (e.g. monitor) –FD:1 Stderr: standard error output stream (usually also on monitor) ) –FD:2

I/O Redirection: Redirecting to a file Redirect between files including the three file descriptors, stdin, stdout and stder Redirecting output: date > file Appending redirecting output: date >> file Redirecting input: Command < input

I/O Redirection: Pipes Pipes connect the standard output of one command to the standard input of another with the pipe symbol |. command1 | command2

Filename Expansion / Globbing Expanding filenames containing special characters Wild cards * ? Square brackets [set]: “-” Special characters: ! (other than) Escaping backslash: protect a subsequent special character

grep grep: search for matches to a pattern in a file and print the matched line to stdout grep Pattern file Pattern could be simple strings or regular expressions

Regular Expression Regular Expression: globbing pattern used for text . : Equivalent to ? in filename expansion .*: any string. Equivalent to * in filename expansion * : zero or more times, a* will match a,aa,…but not ab ^: starting with, ^ab $: ending with, ab$

Regular Expression []: “-” \< \>: exact word

sed and Regular Expressions Stream editor for parses and transform text sed ‘s/abc/xyz’ File: All occurrences sed ‘5,10s/abc/xyz’ File: range, specified lines Sed ‘0~2 s/abc/xyz/’ File: Every other line starting 0 or even lines

Project Write a Bash script to black out sensitive information buried in the files under files/ ./shareFiles.sh finalProject Key tech: editor, chmod, command substitution, for loop, echo, sed, regular expression, i/o redirection