Advanced File Processing Chapter 10 Advanced File Processing
Objectives To discuss the formation and use of regular expressions To explain file compression and how it can be performed To explain the sorting process and how files can be sorted To discuss searching for commands and files in the UNIX file structure To describe searching files for expression, strings and patterns To describe how database-type operations of cutting and pasting fields in a file can be performed To discuss encoding and decoding of files To explain file encryption and decryption To cover the commands and primitives > , ~, compress, crypt, .cut, egrep, fgrep, find, grep… Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Regular Expressions Regular expressions allow you to specify a set of items by using a single character string, similar to the use of shell metacharacters Commonly used tools that allow the use of regular expressions: awk, ed, egrep, grep, sed and vi. Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Regular Expressions (Contd) Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Regular Expressions (Contd) Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Regular Expressions (Contd) Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Regular Expressions (Contd) Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Compressing Files The compress command Compress [options][file-list] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Compressing Files (Contd) The uncompress command Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Compressing Files (Contd) The gzip command gzip [options] [file-list] The gunzip command Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Compressing Files (Contd) The gexe command gexe [options] [file-list] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Compressing Files (Contd) The zcat command zcat [options] [file-list] The pack and unpack commands Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Sorting Ordering a set of items according to some criteria Systems in which sorting is used include: Words in a dictionary Names of people in a telephone directory and so on Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Sorting (Contd) UNIX sort utility sort [options] [file-list] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Searching for Commands and Files find Whereis which Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Searching Files grep [options] pattern [file-list] egrep [options][string][file-list] fgrep [options][expression][file-list] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Cutting and Pasting cut –blist [-n][file-list] cut –clist [file-list] cut –flist [-dchar][-s][file-list] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Cutting and Pasting (Contd) paste [options] file-list Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Encoding and Decoding uuencode [source-file] decode_label uudecode [option] [encoded-file] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
File Encryption and Decryption Encryption is a process by which a file is converted to a form completely different from its original version and that the transformed file in called encrypted file The reverse process of transforming the file to its original form is known as decryption Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
File Encryption and Decryption (Contd) crypt [option] Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
File Encryption and Decryption (Contd) Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
File Encryption and Decryption (Contd) Copyright © 2005 Pearson Addison-Wesley. All rights reserved.