Lab 7: Filtering.

Slides:



Advertisements
Similar presentations
การใช้ระบบปฏิบัติการ UNIX พื้นฐาน บทที่ 4 File Manipulation วิบูลย์ วราสิทธิชัย นักวิชาการคอมพิวเตอร์ ศูนย์คอมพิวเตอร์ ม. สงขลานครินทร์ เวอร์ชั่น 1 วันที่
Advertisements

EMT 2390L Lecture 4 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
A Guide to Unix Using Linux Fourth Edition
The Command Line, Part II, Pine, and Pico CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture.
Uniq command 6/12/2015Gary DeRoest1 report or filter out repeated lines in a file Note: the file needs to be sorted so that repeated lines are adjacent.
 *, ? And [ …] . Any single character  ^ beginning of a line  $ end of the line.
CS 497C – Introduction to UNIX Lecture 24: - Simple Filters Chin-Chih Chang
CS 497C – Introduction to UNIX Lecture 25: - Simple Filters Chin-Chih Chang
Unix Utilities (sort/uniq) CS465 – Unix. The sort command Sorts lines Default behavior: Do a case-sensitive, ascii- alphabetic line sort, starting at.
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Chapter 6 Basic Directory and File Management. Command Line Control Characters Control-s - Stops screen output - rarely used Control-q - Resumes screen.
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.
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.
Using Linux Commands 2 Lab#5
Using Linux Commands 2 Lab#5. Sort command Sort the lines of text files. $ sort fileName by default it will sort in normal order(alphabetical 0-9 A-Z.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Advanced File Processing
CS 403: Programming Languages Lecture 21 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Database A database program is a piece of software to organize and sort information. It creates an electronic list of information that can be sorted very.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
1 Day 5 Additional Unix Commands. 2 Important vs. Not Often in Unix there are multiple ways to do something. –In this class, we will learn the important.
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.
Pipes and Filters Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Chapter Four I/O Redirection1 System Programming Shell Operators.
– Introduction to the Shell 1/21/2016 Introduction to the Shell – Session Introduction to the Shell – Session 3 · Job control · Start,
CSC 352– Unix Programming, Spring 2015 February 2015 Unix Filters.
ORAFACT Text Processing. ORAFACT Searching Inside Files grep - searches for patterns within files grep [options] [[-e] pattern] filename [...] -n shows.
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,
In the last class, Filters and delimiters The sample database pr command head and tail commands cut and paste commands.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
+ Introduction to Unix Joey Azofeifa Dowell Lab Short Read Class Day 2 (Slides inspired by David Knox)
SIMPLE FILTERS. CONTENTS Filters – definition To format text – pr Pick lines from the beginning – head Pick lines from the end – tail Extract characters.
1 Linux Commands. 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full.
Exploring Shell Commands, Streams, and Redirection
Linux 201 Training Module Linux Adv File Mgmt.
Tutorial of Unix Command & shell scriptS 5027
Arrays: Checkboxes and Textareas
Some Linux Commands.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Chapter 6 Filters.
Exploring Shell Commands, Streams, and Redirection
CSE 374 Programming Concepts & Tools
INTRODUCTION TO UNIX: The Shell Command Interface
Exploring Shell Commands, Streams, and Redirection
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Commands
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
Tutorial of Unix Command & shell scriptS 5027
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
More advanced BASH usage
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
Lab 8: Regular Expressions
Software I: Utilities and Internals
Using Linux Command 3 Lab#6.
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
Presentation transcript:

Lab 7: Filtering

What is filtering? Filtering is a process by which a large set of data is restricted by certain conditions to make the data set smaller

Examples Files on GitHub There are three text files that I am using to demonstrate filtering techniques You can download these onto your VMs if you want to follow along random-words.txt random-alphanumeric.txt random-passwords.txt

Head The head command will output the first part of a file The syntax is head [OPTIONS] [FILE] Example: head -5 random-words.txt Head -1 random-passwords.txt

Tail The tail command will output the last part of a file The syntax is tail [options] [file] Examples: tail -5 random-words.txt tail -1 random-passwords.txt

Sorting Sorting is a common filtering technique There is a built-in sort command The syntax is sort [options] [file] Example: sort random-passwords.txt This will sort the contents of the file alphabetically

More Sorting There are numerous options that you can use with the sort command Some common options: -r: this will reverse the sorting -c: this will check to see if the contents are already sorted -o: let’s you specify an output file for sorting

Word Count The wc command will print out information about word count, lines, and bytes in a file wc random-passwords.txt Optional Arguments: -c: display the number of bytes in the file -l: display the number of newline characters in the file -w: display the number of words in the file

Unique Items To see unique items of duplicates in a file, you can use the uniq command The syntax is uniq [options] [file] uniq dups.txt Note: this command only works when duplicate items are adjacent to each other, run the sort command first before using uniq

More & Less The more and less commands can be used to help with reading large files They will display as much information as they can in the terminal and then you can scroll through the rest of it at your own leisure