Jozef Goetz, 2009 1 expanded by Jozef Goetz, 2009 Credits: Parts of the slides are based on slides created by UNIX textbook authors, Syed M. Sarwar, Robert.

Slides:



Advertisements
Similar presentations
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Advertisements

Working with Files How to create, view, copy, rename and print files.
Lab6 CPCS361 I.Mona Alshehri. Working with Files and Directories Creating files Create a file with the cat command type the command cat > name_of_file.
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.
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.
UNIX Chapter 09 Basic File Processing Mr. Mohammad Smirat.
Linux+ Guide to Linux Certification, Second Edition
The Unix Shell. Operating System shell The shell is a command interpreter It forms the interface between a user and the operating system When you log.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
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.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Chapter 4: UNIX File Processing Input and Output.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II CHAPTER 10: ADVANCED FILE PROCESSING.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Advanced File Processing
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
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.
Lesson 11-Locating, Printing, and Archiving User Files.
BIF703 Miscellaneous Commands. File related commands  grep - print lines matching a pattern  head - output the first part of files  tail - output the.
Chapter 3: Command Line Utilities Doin’ stuff. In this chapter … Special characters Redirection More utilities than you shake a stick at.
Unix Basics Chapter 4.
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.
Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working.
Linux+ Guide to Linux Certification, Second Edition
CIT 500: IT Fundamentals Text Processing 1. Topics 1.Displaying files: cat, less, od, head, tail 2.Creating and appending 3.Concatenating files 4.Comparing.
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.
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.
Managing Files. Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
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 9 Basic File Processing. Displaying File Contents cat, cat w/append tac nl pr more less head tail.
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 8: The UNIX File System Continued 1 of 44 Copyright ©2008 by Pearson Education, Inc. Upper.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
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
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Linux Lecture #02. File Related Commands cat --Concatenate and print (display) the content of files. --Also used to create a new file. Syntax cat [Options]
Linux Stuff Last Update Copyright 2014 Kenneth M. Chipps Ph.D. 1.
CSCI 330 UNIX and Network Programming Unit II Basic UNIX Usage: File System.
Jozef Goetz, expanded by Jozef Goetz, 2008 Credits: Parts of the slides are based on slides created by UNIX textbook authors, Syed M. Sarwar, Robert.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Processing.
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.
Learning Unix/Linux Based on slides from: Eric Bishop.
Linux 201 Training Module Linux Adv File Mgmt.
Tutorial of Unix Command & shell scriptS 5027
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Linux file system "On a UNIX system, everything is a file;
Some Linux Commands.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
INTRODUCTION TO UNIX: The Shell Command Interface
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Guide To UNIX Using Linux Third Edition
Tutorial of Unix Command & shell scriptS 5027
Tutorial Unix Command & Makefile CIS 5027
Module 6 Working with Files and Directories
Presentation transcript:

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 Koretsky, Syed A. Sarwar, 2005 Addison Wesley Copyright © 2005 Pearson Addison- Wesley. All rights reserved.

Jozef Goetz, Objectives You may ignore last slides 19 – 24 To discuss how to display contents of a file To explain copying, appending, moving/ renaming, and removing/ deleting files. To describe how to determine the size of a file To discuss commands for comparing files To describe how to combine files To discuss printer control commands To cover the commands and primitives >,>>,^, ~, [ ], *, ?, cancel, cat …

Jozef Goetz, Viewing Contents of Text Files Viewing Complete Files cat [options][file-list] Viewing files One Page at a Time more [options][file-list] -N – display N line per screen/page +N - display the contents at line N and after -pr – display as cat + partitions into pages with a header for each page + /str start 2 lines before the 1 st line containing str Options: -n – display line number

Jozef Goetz, less [options] file-list display files in ‘file-list‘ one screen at a time Options: -N display line number -p pattern search for the first occurrence of ‘pattern’ in the file less -Np 'while' ch9.c less –N my It starts displaying file without reading all the file, which makes more efficient than the more command less command

Jozef Goetz, nl vs cat command nl - display the file with line numbers cs253u]$ nl m 1 date 2 ls -al 3 dir cs253u]$ cat -n m 1 date 2 ls -al 3 dir cs253u]$

Jozef Goetz, Table 9.1 Some Useful less Commands (continued on next slide)

Jozef Goetz, Table 9.1 Some Useful less Commands (continued from previous slide)

Jozef Goetz, Viewing the Head or Tail of a File head [option][file-list] tail [option][file-list] s -n – display 1 st n lines -n – display last n lines see cmd more –n +n – starting with line n -r - reverse order Viewing Contents of Text Files

Jozef Goetz, Copying, Moving and Removing Files Copying Files cp [options] file1 file2 Options: -f force copying if there no write permission on the destination file -i prompt before overwriting -p preserve owner ID, group ID, permissions, and modification time -r recursively copy files and subdirectories

Jozef Goetz, Moving Files mv [options] file1 file2 // move or rename mv [options] file-list directory  Options:  -f force move if there no write permission on the destination file  -i prompt before overwriting $ mv dir/* dir2 - move all files and directories to dir2 Copying, Moving and Removing Files

Jozef Goetz, Removing/Deleting Files rm [options] file-list Options: -f force remove regardless of the permission -i prompt before -r recursively remove files and subdirectories Copying, Moving and Removing Files

Jozef Goetz, Determining File Size ls –l word count wc [options] file-list Options: -l # of lines -w # of words -c # of characters this is the order of display for wc file Copying, Moving and Removing Files

Jozef Goetz, Find find - search for files in a directory hierarchy SYNOPSIS find [path...] [expression] - name - the file being evaluated meets this criterion if filename matches its name -print - display the result find. –name ‘a*’ –print finds and display the filenames of all the files in the working dir, and all subdirectories, that have filenames that begin with a -type c File is of type c: b block (buffered) special c character (unbuffered) special d directory p named pipe (FIFO) f regular file l symbolic link s socket D door (Solaris) find /usr/bin –type d - find the directories in usr/bin find. –type l | wc l - what does it do?

Jozef Goetz, cat [file-list] >> destination-file append at the end of ‘destination-file’ cat [file-list] > destination-file - combine the files in ‘file-list’ and put them in ‘destination-file’ The ‘destination-file’ is overwritten if it already exist Appending to Files and Combining Files cat f1 f2 f3 > f4

Jozef Goetz, diff [options][file1][file2] - display differences line by line Comparing Files

Jozef Goetz, Comparing Files //add 2 lines (w –write, q –quite) and send diff.script //save the differences in diff.script //-e generates and display a script for the ed editor //that can be executed to change Fall_OH to Spring_OH // now Spring_OH is the same as Fall_OH See details p Sarwar, UNIX 2005

Jozef Goetz, uniq [options][+N][input-file][output-file] - remove repetitious lines from the sorted ‘input- file’ and send unique lines to ‘output-file’ $ cat sample This is a test file for the uniq command. It contains some repeated and some nonrepeated lines. Some of the repeated lines are consecutive, like this. And, some are not consecutive, like the following. Some of the repeated lines are consecutive, like this. The above line, therefore, will not be considered a repeated line by the uniq command, but this will be considered repeated! $ uniq sample This is a test file for the uniq command. It contains some repeated and some nonrepeated lines. Some of the repeated lines are consecutive, like this. And, some are not consecutive, like the following. Some of the repeated lines are consecutive, like this. The above line, therefore, will not be considered a repeated line by the uniq command, but this will be considered repeated! $ Options: -c precede each output line by # of occurs -d display repeated lines -u display unrepeated lines Removing Repeated Lines

Jozef Goetz, Removing Repeated Lines uniq [options][+N][input-file][output-file] $ uniq -c sample 1 This is a test file for the uniq command. 1 It contains some repeated and some nonrepeated lines. 3 Some of the repeated lines are consecutive, like this. 1 And, some are not consecutive, like the following. 1 Some of the repeated lines are consecutive, like this. 1 The above line, therefore, will not be considered a repeated 2 line by the uniq command, but this will be considered repeated! $ uniq -d sample Some of the repeated lines are consecutive, like this. line by the uniq command, but this will be considered repeated! $ uniq -d sample out $ cat out Some of the repeated lines are consecutive, like this. line by the uniq command, but this will be considered repeated! $ Options: -c precede each output line by # of occurs -d display repeated lines -u display unrepeated lines

Jozef Goetz, Printing Files

Jozef Goetz, Printing Files and Controlling Print Jobs Printing Files: lp [options] file-list lp Options: -n N print N copies -d prt submit for the ‘ptr’ printer -P page-list print pages specified in page-list // header on every page BSD version:UNIX System V, LINUX versions: lpr Options: -# N print N copies -P prt submit for the ‘ptr’ printer // as above with line numbers lpr [options] file-list

Jozef Goetz, Print Status – System V lpstat - display status of the print jobs lp Options: -d status on the default printer for lp -p printer-list status all specified printers -u user-list status of print jobs from ‘user-list’ -a status all printers

Jozef Goetz, lpq [options] Options: -P printer-list status all specified printers Print Status – BCD

Jozef Goetz, Canceling Your Print Job cancel [options] [printer] Options: -jobID-list cancel jobs specified in ‘jobID-list’ -ulogin cancel jobs that were issued by the user ‘login’ cancel – System V

Jozef Goetz, Canceling Your Print Job (Contd) lprm [options][jobID-list][user(s)] Options: -Pptr print queue for the ‘ptr’ - remove all jobs owned by ‘user’ cancel – BSD