This Month's Underprepared Command Line Talk Part Three

Slides:



Advertisements
Similar presentations
UNIX Chapter 12 Redirection and Piping Mr. Mohammad Smirat.
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.
A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 4: More Command Line Interface (CLI) Chapter 7: The Linux Shell By Fred R. McClurg Linux.
Introduction to UNIX CSE 2031 Fall May 2015.
It's a binary file kept under specific directory.
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Josh Goodwin
CS-502 Fall 2006Project 1, Fork1 Programming Project 1 – Fork.
CS 497C – Introduction to UNIX Lecture 21: - The Shell Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Grep, comm, and uniq. The grep Command The grep command allows a user to search for specific text inside a file. The grep command will find all occurrences.
CSCI 330 T HE UNIX S YSTEM File operations. OPERATIONS ON REGULAR FILES 2 CSCI The UNIX System Create Edit Display Contents Display Contents Print.
Introduction to Unix – CS 21 Lecture 5. Lecture Overview Lab Review Useful commands that will illustrate today’s lecture Streams of input and output File.
CSC 4630 Meeting 2 January 22, Filters Definition: A filter is a program that takes a text file as an input and produces a text file as an output.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
PIPE AND FILTER GROUP 2 SHIMIRRAH REMBERT CHRISTOPER BELL ADEDOYIN OKE BRIAN ADIYIAH BRELAND BRANCH.
Shell Script Examples.
1 Day 16 Sed and Awk. 2 Looking through output We already know what “grep” does. –It looks for something in a file. –Returns any line from the file that.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II CHAPTER 10: ADVANCED FILE PROCESSING.
Advanced File Processing
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Agenda Basic Shell Operations Standard Input / Output / Error Redirection of Standard Input / Output / Error ( >, >>,
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT I/O Redirection.
Guide To UNIX Using Linux Fourth Edition
LIN 6932 Unix Lecture 6 Hana Filip. LIN 6932 HW6 - Part II solutions posted on my website see syllabus.
The “File System” Under UNIX, (almost) everything is a “file”: –Normal files –Directories –Hardware –Sockets –Pipes Things that are not files: –Users –Groups.
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.
Summer 2015 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to UNIX / Linux - 7 Dr. Jerry Shiao, Silicon Valley University.
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
Chapter Five Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command.
Module 6 – Redirections, Pipes and Power Tools.. STDin 0 STDout 1 STDerr 2 Redirections.
Pipes and Filters Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
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.
1 Unix Seminar #1 T.J. Borrelli Lecturer for CS and NSSA February 6th, 2009.
Pipes & Filters Architecture Pattern Source: Pattern-Oriented Software Architecture, Vol. 1, Buschmann, et al.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Chapter Four I/O Redirection1 System Programming Shell Operators.
Unix, Linux, DOS, Windows Command Line CSE 660 May 12, 2008.
40 Years and Still Rocking the Terminal!
Operating Systems Lecture 10. Agenda for Today Review of previous lecture Input, output, and error redirection in UNIX/Linux FIFOs in UNIX/Linux Use of.
Week 9 - Nov 7, Week 9 Agenda I/O redirection I/O redirection pipe pipe tee tee.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Uniq The uniq command is useful when you need to find duplicate lines in a file. The basic format of the command is uniq in_file out_file In this format,
UNIX commands Head More (press Q to exit) Cat – Example cat file – Example cat file1 file2 Grep – Grep –v ‘expression’ – Grep –A 1 ‘expression’ – Grep.
6/13/2016Course material created by D. Woit 1 CPS 393 Introduction to Unix and C START OF WEEK 3 (UNIX) 6/13/2016Course material created by D. Woit 1.
Week 3 Redirection, Pipes, and Background
Input from STDIN STDIN, standard input, comes from the keyboard.
regular expressions - grep
Chapter 6 Filters.
Unix Scripting Session 4 March 27, 2008.
Unix Operating System (Week Two)
Advanced GNU/Linux Command Line By: - Mohammed El-Sayed.
Sarah Diesburg Operating Systems CS 3430
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
The Linux Command Line Chapter 6
Guide To UNIX Using Linux Third Edition
Unix Talk #2 grep/egrep/fgrep (maybe add more to this one….)
Chapter Four UNIX File Processing.
Exploring Shell Commands, Streams, and Redirection
MeasureCamp VI *NIX for ETL
More advanced BASH usage
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Lecture 4 Redirecting standard I/O & Pipes
Software I: Utilities and Internals
Exploring Shell Commands, Streams, and Redirection
Short Read Sequencing Analysis Workshop
Presentation transcript:

This Month's Underprepared Command Line Talk Part Three formerly known as HUMAN CENTIPEDE David Spencer Bradford Linux Users Group 26th September 2012

Last time

Last time

This time

Next time

This time

Notation cmd1 | cmd2

Notation cmd1 | cmd2 | cmd3 cmd1 < inputfile cmd2 > outputfile

Unix / C input and output 0 stdin 1 stdout 2 stderr

Efficient implementation (in the kernel) cmd1 | cmd2 Efficient implementation (in the kernel) No worries about buffering, synchronisation, resources

cmd1 >> outputfile cmd2 < inputfile cmd2 <infile >outfile

Trivial examples Print the name of the newest file ls -t | head -1 Print how many files ls | wc -l Concatenate three files cat file1 file2 file3 > allfiles

Filter Input stream transform Output stream

tr sort grep cut sed gzip bzip2 xz fmt fromdos ffmpeg Filters tr sort grep cut sed gzip bzip2 xz fmt fromdos ffmpeg and many many many more

More useful examples dd bs=512 < /dev/cdrom > rip.iso cmp - originalimage.iso

Guess what this does ssh user@host 'mpg321 -' < fart.mp3

Copy a disk image over the net ddrescue bs=512 < /dev/sda | \ gzip | \ ssh user@host 'cat > sda.img.gz'

Error messages don't pass down the pipeline... Standard error Error messages don't pass down the pipeline... ... unless you want them to cmd1 |& cmd2 cmd1 2>&1 | cmd2

A famous example Read a file of text Determine the n most frequently used words Print out a sorted list of those words along with their frequencies

Copious documentation Knuth's solution "Literate programming" 10 pages of Pascal Custom data structure Copious documentation

McIlroy's solution tr -cs A-Za-z '\n' | \ tr A-Z a-z | \ sort | \ uniq -c | \ sort -rn | \ head -n

Recap of notation cmd1 <infile | cmd2 | cmd3 >outfile cmd1 >>appendfile cmd1 |& cmd2 cmd1 >/dev/null 2>&1 cmd1 &> /dev/null long_command --with-args \ --and-some <more_args

We learned something today

You can couple programs like garden hose Finding appropriate programs is your job