The Linux Command Line Chapter 6

Slides:



Advertisements
Similar presentations
UNIX Chapter 12 Redirection and Piping Mr. Mohammad Smirat.
Advertisements

การใช้ระบบปฏิบัติการ UNIX พื้นฐาน บทที่ 4 File Manipulation วิบูลย์ วราสิทธิชัย นักวิชาการคอมพิวเตอร์ ศูนย์คอมพิวเตอร์ ม. สงขลานครินทร์ เวอร์ชั่น 1 วันที่
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.
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
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.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
UNIX Filters.
1 UNIX essentials (hands-on) the directory tree running programs the shell (using the T-shell) → command line processing → special characters → command.
Advanced File Processing
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
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.
Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Unix programming Term: III B.Tech II semester Unit-II PPT Slides Text Books: (1)unix the ultimate guide by Sumitabha Das (2)Advanced programming.
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 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!)
1 UNIX essentials (hands-on) the directory tree running programs the shell → command line processing → special characters → command types → shell variables.
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
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.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Chapter Four I/O Redirection1 System Programming Shell Operators.
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.
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.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
SIMPLE FILTERS. CONTENTS Filters – definition To format text – pr Pick lines from the beginning – head Pick lines from the end – tail Extract characters.
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Linux 201 Training Module Linux Adv File Mgmt.
Tutorial of Unix Command & shell scriptS 5027
Lesson 5-Exploring Utilities
Some Linux Commands.
Chapter 6 Filters.
Unix Operating System (Week Two)
The Linux Command Line Chapter 14
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
A Practical Guide to Linux® Commands, Editors, and Shell Programming
The Linux Command Line Chapter 2
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Guide To UNIX Using Linux Third Edition
The Linux Command Line Chapter 7
The Linux Command Line Chapter 18
Presented by, Mr. Satish Pise
Tutorial of Unix Command & shell scriptS 5027
The Linux Command Line Chapter 3
The Linux Command Line Chapter 28
Exploring Shell Commands, Streams, and Redirection
The Linux Command Line Chapter 17
More advanced BASH usage
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
The Linux Command Line Chapter 4
Lecture 4 Redirecting standard I/O & Pipes
Lab 7: Filtering.
Exploring Shell Commands, Streams, and Redirection
The Linux Command Line Chapter 3
The Linux Command Line Chapter 4
LPI Linux Certification
Exploring Shell Commands, Streams, and Redirection
Presentation transcript:

The Linux Command Line Chapter 6 Redirection Prepared by Dr. Reyes, New York City College of Technology

Outline Redirection Pipelines Patterns Expansions Shell Arithmetic Brace Expansion Escape Characters

Redirection stdout – default output stream To redirect output from stdout use > ls -l /usr/bin > ls-output.txt This will create a file named ls-output.txt containing the output of the command at the left hand side of > To redirect and append use >> ls -l /usr/bin >> ls-output.txt This will append the output of the command at the left hand side of >> to the file ls-output.txt, create it if it does not exist.

Redirection cat – reads one or more files and copies them to standard output Syntax Example To redirect input use <

Pipelines Pipelines allows you to redirect the output of one command and pipe it as input to another The operator is the vertical bar | Usage: command1 | command2 | … | commandN ls -l /usr/bin | less

Filters sort – sorts the input uniq – removes duplicates ls /bin /usr/bin | sort | less uniq – removes duplicates ls /bin /usr/bin | sort | uniq | less ls /bin /usr/bin | sort | uniq -d | less wc - command used to display the number of lines, words, and bytes contained in files. wc ls-output.txt

Patterns grep – a powerful program that allows you to find text patterns within files. When grep finds the pattern, it prints out the lines containing it. ls /bin /usr/bin | sort | uniq | grep zip head - prints the first 10 lines of a file head ls-output.txt head -n 5 ls-output.txt tail - prints the last 10 lines of a file tail ls-output.txt tail -n 5 ls-output.txt tail -f /var/log/messages Special command used for real-time monitoring, exit with ctrl+C tee - reads standard input and copies it to both standard output and to one or more files ls /usr/bin | tee ls.txt ls /usr/bin | tee ls.txt | grep zip