Скачать презентацию Chapter 9 Basic File Processing Objectives Скачать презентацию Chapter 9 Basic File Processing Objectives

61ec86adf1f0921a9bb56d4f54894792.ppt

  • Количество слайдов: 17

Chapter 9 Basic File Processing Chapter 9 Basic File Processing

Objectives • To discuss how to display contents of a file • To explain Objectives • 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 … Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Viewing Contents of Text Files • Viewing Complete Files – cat [options][file-list] • Viewing Viewing Contents of Text Files • Viewing Complete Files – cat [options][file-list] • Viewing files One Page at a Time – more [options][file-list] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Viewing Contents of Text Files (Contd) • Viewing the Head or Tail of a Viewing Contents of Text Files (Contd) • Viewing the Head or Tail of a File – head [option][file-list] – tail [option][file-list] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Copying, Moving and Removing Files • Copying Files – cp [options] file 1 file Copying, Moving and Removing Files • Copying Files – cp [options] file 1 file 2 • Options: -f, -i , -p, -r Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Copying, Moving and Removing Files (Contd) • Moving Files – mv [options] file 1 Copying, Moving and Removing Files (Contd) • Moving Files – mv [options] file 1 file 2 – mv [options] file-list directory Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Copying, Moving and Removing Files (Contd) • Removing/ Deleting Files – rm [options] file-list Copying, Moving and Removing Files (Contd) • Removing/ Deleting Files – rm [options] file-list Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Copying, Moving and Removing Files (Contd) • Determining File Size – ls –l – Copying, Moving and Removing Files (Contd) • Determining File Size – ls –l – wc [options] file-list Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Appending to Files and Comparing Files cat [file-list] >> destination-file diff [options][file 1][file 2] Appending to Files and Comparing Files cat [file-list] >> destination-file diff [options][file 1][file 2] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Comparing Files Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Comparing Files Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Removing Repeated Lines uniq [options][+N][input-file][output-file] $ cat sample This is a test file for Removing Repeated Lines uniq [options][+N][input-file][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! $ Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Removing Repeated Lines uniq [options][+N][input-file][output-file] $ uniq -c sample 1 This is a test 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! $ Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Printing Files Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Printing Files Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Printing Files and Controlling Print Jobs • Printing Files lp [options] file-list lpr [options] Printing Files and Controlling Print Jobs • Printing Files lp [options] file-list lpr [options] file-list Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Printing Files and Controlling Print Jobs (Contd) – lpq [options] Copyright © 2005 Pearson Printing Files and Controlling Print Jobs (Contd) – lpq [options] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Printing Files and Controlling Print Jobs (Contd) • Canceling Your Print Job – cancel Printing Files and Controlling Print Jobs (Contd) • Canceling Your Print Job – cancel [options] [printer] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.

Printing Files and Controlling Print Jobs (Contd) • Canceling Your Print Job (Contd) – Printing Files and Controlling Print Jobs (Contd) • Canceling Your Print Job (Contd) – lprm [options][job. ID-list][user(s)] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.