1 제 3 장 유틸리티 숙명여대 창병모 2009.09. 2 파일 조작 filtering, sorting, comparing, searching for files 명령어 스케줄링 cron, at 텍스트 처리 프로그램 AWK 파일 보관 및 압축 archiving tar,

Slides:



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

LINUX System : Lecture 3 (English-Only Lecture) Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University Acknowledgement.
1 Unix Talk #2 AWK overview Patterns and actions Records and fields Print vs. printf.
Grep (Global REgular expresion Print) Operation –Search a group of files –Find all lines that contain a particular regular expression pattern –Write the.
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 6.
2000 Copyrights Danielle S. Lahmani UNIX Tools G , Fall 2000 Danielle S. Lahmani Lecture 5.
Introduction to Unix – CS 21 Lecture 13. Lecture Overview Finding files and programs which whereis find xargs Putting it all together for some complex.
CS 497C – Introduction to UNIX Lecture 23: - Simple Filters 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.
UNIX. find command ● The find command is used to locate files on a Unix or Linux system. find will search any set of directories you specify for files.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
UNIX Filters.
Chapter 3 UNIX Utilities for Power Users Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Original.
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.
Linux Tools. Tar tar – (Tape Archive). This is a tool for archiving files and directory hierarchies. tar output can be sent to stdout using the – file.
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.
Offline File Storage. Module 12 Offline File Storage ♦ Introduction Backup is usually done by first collecting all the data in a single archive file,
June 1, 1999Manipulating Files1 Introduction to UNIX E. Manipulating Files.
Lesson 11-Locating, Printing, and Archiving User Files.
Agenda Sed Utility - Advanced –Using Script-files / Example Awk Utility - Advanced –Using Script-files –Math calculations / Operators / Functions –Floating.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
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.
Dedan Githae, BecA-ILRI Hub Introduction to Linux / UNIX OS MARI eBioKit Workshop; Nov , 2014.
Linux Operations and Administration
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
CS 403: Programming Languages Fall 2004 Department of Computer Science University of Alabama Joel Jones.
Find Find basics. find ~ -name myfile –print find directory criteria This will search the home directory (~) looking for files.
1 Lecture 5 Additional useful commands COP 3353 Introduction to UNIX.
Workbook 5 - Part 2 The Linux Filesystem RH030 Linux Computing Essentials.
Module 6 – Redirections, Pipes and Power Tools.. STDin 0 STDout 1 STDerr 2 Redirections.
Introduction to Awk Awk is a convenient and expressive programming language that can be applied to a wide variety of computing and data manipulation tasks.
Programmable Text Processing with awk Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: “UNIX for Programmers and Users”
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
Xuan Guo Chapter 3-2 Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, CSc
I/O Redirection and Regular Expressions February 9 th, 2004 Class Meeting 4.
Introduction to Unix – CS 21 Lecture 12. Lecture Overview A few more bash programming tricks The here document Trapping signals in bash cut and tr sed.
LIN Unix Lecture 7 Hana Filip. LIN Text Processing Command Line Utility Programs (cont.) sed LAST WEEK wc sort tr uniq awk TODAY join paste.
(Re)introduction to Unix Sarah Medland. So Unix…  Long and venerable history  
Getting the most out of the workshop Ask questions!!! Don’t sit next to someone you already know Work with someone with a different skillset and different.
숙명여대 창병모 2011 가을 1. 파일 조작  filtering, sorting, comparing, searching for files 명령어 스케줄링  cron, at 텍스트 처리 프로그램  AWK 파일 보관 및 압축  archiving  tar, gzip.
Chapter 7 UNIX Utilities for Power Users Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Original.
Awk- An Advanced Filter by Prof. Shylaja S S Head of the Dept. Dept. of Information Science & Engineering, P.E.S Institute of Technology, Bangalore
1 P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Awk Programming Ruibin Bai (Room AB326) Division of Computer Science The University.
Alon Efrat Computer Science Department University of Arizona Unix Tools.
The awk command. Introduction Awk is a programming language used for manipulating data and generating reports. The data may come from standard input,
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 3 rd, 2009 Essential Unix Commands …the second half.
Why UNIX? In the 1980s, UNIX became popular In the 1980s, UNIX became popular Customer demand for open systems: Customer demand for open systems: Application.
Sed. Class Issues vSphere Issues – root only until lab 3.
1 Lecture 10 Introduction to AWK COP 3344 Introduction to UNIX.
CSCI 330 UNIX and Network Programming Unit IX: awk II.
Chapter 3 UNIX Utilities for Power Users Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, 2003.
Chapter 3 UNIX Utilities for Power Users Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Original.
Chapter 19 File System Backup. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To describe how files and directories can be archived.
Awk 2 – more awk. AWK INVOCATION AND OPERATION the "-F" option allows changing Awk's "field separator" character. Awk regards each line of input data.
AWK One tool to create them all AWK Marcel Nijenhof Eth-0 11 Augustus 2010.
Lesson 5-Exploring Utilities
Advanced File Processing
Chapter 6 Filters.
PROGRAMMING THE BASH SHELL PART IV by İlker Korkmaz and Kaya Oğuz
CS 403: Programming Languages
John Carelli, Instructor Kutztown University
Lecture 5 Additional useful commands COP 3353 Introduction to UNIX 1.
Prepared by, Mr. Satish Pise
Awk.
Software I: Utilities and Internals
Lecture 5 Additional useful commands COP 3353 Introduction to UNIX 1.
Review.
Presentation transcript:

1 제 3 장 유틸리티 숙명여대 창병모

2 파일 조작 filtering, sorting, comparing, searching for files 명령어 스케줄링 cron, at 텍스트 처리 프로그램 AWK 파일 보관 및 압축 archiving tar, gzip 유용한 유틸리티

파일 조작 3

4 filter all lines containing a specified pattern 파일 필터링

5 %grep -wn the grepfile %grep -wnv the grepfile %grep -w x *.c %grep -wl x *.c %grep “.nd” grepfile %grep “sm.*ng” grepfile %grep “[a-m]nd” grepfile grep: 예

6 Sorting files sort -tc -r {sortField -bfMn}* {fileName}* - sorts files in ascending or descending order - based on sort field(s) Comparing files cmp -ls fileName1 fileName2 testing for the sameness diff -i -dflag fileName1 fileName2 file differences 파일 정렬 / 비교

7 %sort -r sortfile %sort sortfile %sort bM sortfile %cmp lady1 lady2 %cmp -l lady1 lady2 %diff lady1 lady2 파일 정렬 / 비교 : 예

8 find pathList expression recursively descends through pathList and applies expression to every file. expression -name pattern -user userId -atime count -print -ls -exec command 파일 찾기

9 %find. -name '*.c' -print %find. -user chang -ls %find. -mtime 14 -ls %find. -mtime 14 -ls -exec rm {} \; 파일 찾기 : 예

명령어 스케줄링 10

11 주기적 실행 : cron

12 주기적 실행 : cron

텍스트 처리 프로그램 :AWK 13

14 AWK Unix 에서 처음 개발된 일반 스 크립트 언어 스 크립트 언어 텍스트 형태로 되어있는 데이 터를 필드로 구분하여 처리하 는 기능을 기본으로 한다. Alfred Aho, Peter Weinberger, Brian Kernighan

15 awk -Fc [-f fileName] program {fileName}* Scans the lines and performs actions on every line that matches a condition awk program is a list of commands of the form [ condition] [ { action } ] Examples awk ‘{ print NF, $0}’ float awk ‘{ print $1 $3 $NF}’ float awk ‘NR > 1 && NR <4 { print NR, $1, $3, $NF}’ float AWK

16 AWK Condition the special token BEGIN or END an expression involving logical operators, relational operators, and/or regular expressions

17 AWK Action if (conditional) statement [else statement] while (conditional) statement for (expression; conditional; expression) statement break continue variable=expression

18 AWK Action print [list of expressions] printf format [, list of expressions] next skips the remaining patterns of the current line of input) exit skips the rest of the current line) {list of statements}

19 awk2 BEGIN { print “Start of file:”, FILENAME } { print $1 $3 $NF } END { print “End of file” } awk -f awk2 float awk4 BEGIN { print “Scanning file” } { printf “line %d: %s\n”, NR, $0; lineCount++; wordCount + = NF } AWK: 예

20 awk5 {for (I = NF; I >= 1; I--) printf “%s “, $I printf “\n” } awk6 /t.*e/ {print $0} awk7 /strong/, /clear/ { print $0} AWK: 예

파일 보관 / 압축 21

22 three utilities to archive files save files to a disk or tape tar, cpio, dump tar maintain an archive of files on a magnetic tape create and access special tar-format archive files a file can be added on the end of tar-format file tar -cfrtuvx [tarFileName] fileList 파일 보관

23 % tar -cvf tarfile. % tar -xvf tarfile % tar -rvf tarfile reverse.c % tar -cvf /dev/rst0 * 파일 보관 : 예

24 compress -cv {fileName}+ replaces a file by its compressed version(.Z) -c option sends the compressed version to standard output uncompress -cv {fileName}+ re-creating the original file from its compressed file %compress -v a.c b.c %uncompress *.Z 파일 압축 : compress

25 gzip {fileName}+ replaces a file by its compressed version(.gz) -c option sends the compressed version to standard output gzip -d {fileName}+ decompress the original files from its compressed file gzip -l {fileName}+ list compressed file contents %gzip -v a.c b.c %gzip –d *.gz 파일 압축 : gzip