EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.

Slides:



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

การใช้ระบบปฏิบัติการ UNIX พื้นฐาน บทที่ 4 File Manipulation วิบูลย์ วราสิทธิชัย นักวิชาการคอมพิวเตอร์ ศูนย์คอมพิวเตอร์ ม. สงขลานครินทร์ เวอร์ชั่น 1 วันที่
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Josh Goodwin
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
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.
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.
LINUX COMMAND LINE INTERFACE Lab 3 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
1 UNIX essentials (hands-on) the directory tree running programs the shell (using the T-shell) → command line processing → special characters → command.
Introduction to Linux and Shell Scripting Jacob Chan.
Advanced File Processing
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
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!)
EMT 2390L Lecture 6 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
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.
EMT 2390L Lecture 8 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
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.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
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.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
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.
EMT 2390L Lecture 5 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
EMT 2390L Lecture 9 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
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.
– Introduction to the Shell 1/21/2016 Introduction to the Shell – Session Introduction to the Shell – Session 3 · Job control · Start,
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
EMT 2390L Lecture 3 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
© Prepared By: Razif Razali 1 TMK 265: UNIX SYSTEM CHAPTER FOUR – QUOTING IN DETAIL.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
CIRC Summer School 2016 Baowei Liu
Linux 201 Training Module Linux Adv File Mgmt.
Lesson 5-Exploring Utilities
The UNIX Shell Learning Objectives:
CIRC Winter Boot Camp 2017 Baowei Liu
Chapter 6 Filters.
CSE 303 Concepts and Tools for Software Development
Exploring Shell Commands, Streams, and Redirection
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
The Linux Command Line Chapter 6
Guide To UNIX Using Linux Third Edition
The Linux Command Line Chapter 7
Tutorial of Unix Command & shell scriptS 5027
Exploring Shell Commands, Streams, and Redirection
More advanced BASH usage
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Lecture 4 Redirecting standard I/O & Pipes
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
LPI Linux Certification
Presentation transcript:

EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts

Outline Redirection Pipelines Patterns Expansions Shell Arithmetic Brace Expansion Escape Characters

Redirection stdout – default output stream To redirect output from stdout use > o ls -l /usr/bin > ls-output.txt o less ls-output.txt To redirect and append use >> o ls -l /usr/bin >> ls-output.txt cat – reads one or more files and copies them to standard output o Usage: cat file1 file2 … fileN o cat > lazy_dog.txt o cat lazy_dog.txt To redirect input use < o cat < lazy_dog.txt

Pipelines Pipelines allows you to redirect the output of one command and pipe it as input to another The operator is the vertical bar | o Usage: command1 | command2 | … | commandN o ls -l /usr/bin | less sort – sorts the input o ls /bin /usr/bin | sort | less uniq – removes duplicates o ls /bin /usr/bin | sort | uniq | less o ls /bin /usr/bin | sort | uniq -d | less wc - command used to display the number of lines, words, and bytes contained in files. o 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. o ls /bin /usr/bin | sort | uniq | grep zip head - prints the first 10 lines of a file o head ls-output.txt o head -n 5 ls-output.txt tail - prints the last 10 lines of a file o tail ls-output.txt o tail -n 5 ls-output.txt o tail -f /var/log/messages //Real-time monitoring, exit with ctrl+C tee - reads standard input and copies it to both standard output and to one or more files o ls /usr/bin | tee ls.txt o ls /usr/bin | tee ls.txt | grep zip

Expansion echo – command used to display a line of text o echo Hello When using wildcards and certain commands with special meaning, Linux “expand” these command before executing them o echo * o echo D* o echo *s o echo ~

Shell Arithmetic Uses the format $((expression)) o echo $((2 + 2)) o echo $(($((5**2)) * 3))

Brace Expansion Allows you to create multiple text strings that follows a certain pattern o echo Front-{A,B,C}-Back o echo Number_{1..5} o echo {Z..A} You may use echo to read environment variables o echo $USER o echo $PATH When using strings, surround them with double quotes

Escape Characters Characters such as $, !, & have special meaning To use them you must use escape characters which basically means putting a backslash before the character o echo "The balance for user $USER is: \$5.00"

Assignments Check the class OpenLab site for new Labs Check Blackboard for new Quizzes