Lesson 11-Locating, Printing, and Archiving User Files.

Slides:



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

Working with Files How to create, view, copy, rename and print files.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
2000 Copyrights, Danielle S. Lahmani UNIX Tools G , Fall 2000 Danielle S. Lahmani Lecture 12.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Chapter 11 UNIX Printing. have to be root to setup a printer local printer is directly connected remote printer is a network printer print queue is nothing.
Linux+ Guide to Linux Certification, Second Edition
Guide To UNIX Using Linux Third Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Linux+ Guide to Linux Certification, Second Edition
CS 497C – Introduction to UNIX Lecture 13: - The File System Chin-Chih Chang
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.
Lecture 8 Configuring a Printer-using Magic Filter Introduction to IP Addressing.
Linux Commands LINUX COMMANDS.
Chapter 4: UNIX File Processing Input and Output.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Ch 51 Internal Commands COPY and TYPE. Ch 52 Overview Will review file-naming rules.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Offline File Storage. Module 12 Offline File Storage ♦ Introduction Backup is usually done by first collecting all the data in a single archive file,
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Working with Files Chapter 5. Display a Calendar Display a calendar for a specific month – cal Display a calendar for a specific year – cal 2000.
June 1, 1999Manipulating Files1 Introduction to UNIX E. Manipulating Files.
BIF703 Miscellaneous Commands. File related commands  grep - print lines matching a pattern  head - output the first part of files  tail - output the.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Introduction to Unix (CA263) File Processing. Guide to UNIX Using Linux, Third Edition 2 Objectives Explain UNIX and Linux file processing Use basic file.
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.
Linux Operations and Administration
Linux+ Guide to Linux Certification, Second Edition
Jozef Goetz, expanded by Jozef Goetz, 2009 Credits: Parts of the slides are based on slides created by UNIX textbook authors, Syed M. Sarwar, Robert.
Day 7 Installing Software RPM tar, mtools make, ssh.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
Find Find basics. find ~ -name myfile –print find directory criteria This will search the home directory (~) looking for files.
Workbook 5 - Part 2 The Linux Filesystem RH030 Linux Computing Essentials.
Linux+ Guide to Linux Certification, Third Edition
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
Guide To UNIX Using Linux Third Edition Chapter 8: Exploring the UNIX/Linux Utilities.
BIF713 Additional Utilities. Linux Utilities  You have learned many Linux commands. Here are some more that you can use:  Data Manipulation (Reg Exps)
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
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.
Introduction to Unix (CA263) File Editing By Tariq Ibn Aziz.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
ULI101 More Linux Commands Introduction to UNIX/Linux and the Internet
Introduction to Programming Using C An Introduction to Operating Systems.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Linux Commands C151 Multi-User Operating Systems.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 3 rd, 2009 Essential Unix Commands …the second half.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
CSCI 330 UNIX and Network Programming Unit II Basic UNIX Usage: File System.
Lesson 6-Using Utilities to Accomplish Complex Tasks.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Tutorial of Unix Command & shell scriptS 5027
Lesson 5-Exploring Utilities
C151 Multi-User Operating Systems
INTRODUCTION TO UNIX: The Shell Command Interface
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Chapter Four UNIX File Processing.
Introduction Paul Flynn
CIS 155 Lecture 10, Farewell to UNIX
Presentation transcript:

Lesson 11-Locating, Printing, and Archiving User Files

Overview Creating a long file. Splitting long files. Locating files with find. Printing a file. Archiving files.

Creating a Long File The “ls –R ~” command is used to list all the files contained in the user’s home directory. The “cut –c range of characters ~/file name” command is used to read a particular number of characters from each line in a file. The “cat –n file name” command is used to add numbers to the left of all lines in a copy of the file.

Splitting Long Files The “split” utility is used to read a long file and break up the contents into a series of small files of specified size. Each small file has an extension starting with “aa” and going through the alphabet as far as needed to hold a copy of the whole file.

Splitting Long Files Splitting Long Files into Pieces

Splitting Long Files Reassembling the files: The “cat filename*” command is used to read all the small files and output data that matches the original long file. The last part of the file names, such as “aa”, “ab”, etc., is in ASCII order. The ASCII order is used by the shell for the filenames when it replaces the * in the command line.

Locating File with Find The “find” utility is used to locate a particular file in several directories. The find utility displays the output and any error message that is appropriate. The pathnames of files and information about directories that cannot be examined because of their assigned permissions are also displayed by the find utility.

Locating File with Find The command to be given is “find ~ -name filename – print”. The “~” specifies the target starting point directory. The “–print” specifies that the full pathname of each occurrence of the file(s) matching the selection criterion should be output to the screen.

Locating File with Find Locating files by owner. Locating and acting on files by owner. Locating additional options. Acting on all files in a directory tree.

Locating Files by Owner The “ls –ld /directory name/$USER” command is used to determine if the user has a directory with the same name as the login name in a particular directory. The “find” utility can also be used to identify files owned by a particular user. The output of the find utility can be redirected to a file or a printer.

Locating Files by Owner Command Line Interpretation find Utility

Locating and Acting on Files by Owner The find utility can also be used to remove located files, change file permissions, or employ any shell file- manipulation command. The “-exec” option is used with the utility to execute any command utilizing the file names that are selected.

Locating and Acting on Files by Owner Using the find Utility to Locate Files by Owner

Locating Additional Options Additional Options

Acting on all Files in a Directory Tree The find utility can be used as an agent to go through the directory tree recursively and execute another utility on all files. The utility shows a user to search through the specified directory trees, based on a variety of criteria, and perform actions on the located files.

Printing a File Printing the output of a pipeline. Printing multiple copies. Adding a title line to the banner page. Checking the status of print jobs. Canceling a print request.

Printing the Output of a Pipeline A pipe can be used to connect the output of a utility as an input to the print utility. The “col –bx” and the “colcrt” utilities are used to remove control characters that are of value to the terminal.

Printing Multiple Copies Any of the following commands can be used to print multiple copies of a file: lp –n (number of copies to be printed in numeric value) file name. lpr -# (number of copies to be printed in numeric value) file name.

Adding a Title Line to the Banner Page A banner page, also called the burst page, contains information about the printer and the user issuing the print request. The “lp –t‘numbers file’ file name” or the “lpr –Pprinter – J’numbers file’ file name” command can be used to add a title and print the file.

Adding a Title Line to the Banner Page The “lp –dprinter –ttitle filename” or the “lpr –Pprinter – J’title’ filename” are the two formats of the print commands.

Checking the Status of Print Jobs All print requests are administered by a spooler. A spooler is a program that receives print requests from multiple users and sends jobs one at a time to the printer. The spooler makes it possible for the system to process simultaneous print job requests for several users. The “lpstat” or the “lpq –Pprinter username” command can be use to examine the queue.

Canceling a Print Request The “cancel” or the “lprm” command can be used to remove jobs from the queue. On a Linux system, all printing jobs owned by the user are removed from the queue. On a UNIX system, the “–u” option is used to indicate jobs owned by the user.

Archiving Files Archiving files on floppy disks. Creating archives with tar.

Archiving Files on Floppy Disks Copying a file to and from a floppy: Mtools is a set of programs that facilitate the copying of files to a floppy drive without going through the process of mounting the drive. The “mcopy” command is used to copy a file to and from a floppy. The command requires two arguments the file name from the current directory, and a:, which is an agreed name for the floppy.

Archiving Files on Floppy Disks Copying a file to and from a floppy (continued): Multiple files can be copied by using the * sign in place of a particular filename. Attributes such as permissions are not included in the copy. When a file is copied from a floppy, the permissions for the newly copied file may not match its original permissions. When the mcopy command creates a new file on the system, the default permissions for the new file are applied.

Archiving Files on Floppy Disks Removing files and directories from a floppy: The “mdel” command is used to delete files. The mdel command requires an argument, the name of the file(s) to be deleted. The “mdeltree” command is used to delete directories. This command requires one argument, the name of the directory to be deleted.

Archiving Files on Floppy Disks Formatting a floppy disk: The “mformat” command is used to format a floppy. The floppy is formatted in the DOS format.

Creating Archives with tar The “tar” (tape archiving) utility is used extensively for making archive files on most systems. The utility can be used to create a single file, called archive, which contains the files in a directory tree and all information about each file.

Creating Archives with tar The command used to create a tar archive is “tar –cvf filename.tar”. The command instructs tar to create an archive in verbose mode and use a file to hold the archive. The dot (.) is the source directory, from which all files are archived. The “tar –tf filename” can be used to list the contents of the tar archive.

Creating Archives with tar Extracting files from an archive: The extension “.tar” is called a “tarball”. A tarball can be moved, mailed, or placed on portable media. The “tar –xvf filename.tar” is used to extract the directory tree from the archive. The command provides instructions to extract the structure from the archive in verbose mode, from a file.

Summary The split utility is used to break the contents of a long file into a series of small files. The lp and the lpr utilities manage files directed to the printer. The find utility searches through a directory tree for files based on specific criteria, and then takes action on each identified file.

Summary The mtools utility facilitates the copying of files to and from a floppy drive using a DOS-formatted floppy. The tar utility is used to make an archive of a directory tree or a file. The archive can be stored on permanent media, sent to a remote machine, or just used to move a structure from one location in a system to another.