Presentation is loading. Please wait.

Presentation is loading. Please wait.

숙명여대 창병모 2011 가을 1. 파일 조작  filtering, sorting, comparing, searching for files 명령어 스케줄링  cron, at 텍스트 처리 프로그램  AWK 파일 보관 및 압축  archiving  tar, gzip.

Similar presentations


Presentation on theme: "숙명여대 창병모 2011 가을 1. 파일 조작  filtering, sorting, comparing, searching for files 명령어 스케줄링  cron, at 텍스트 처리 프로그램  AWK 파일 보관 및 압축  archiving  tar, gzip."— Presentation transcript:

1 숙명여대 창병모 2011 가을 1

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

3 3

4 filter all lines containing a specified pattern 4

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 5

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 6

7 %sort -r sortfile %sort +0 -1 sortfile %sort +0 -1 -bM sortfile %cmp lady1 lady2 %cmp -l lady1 lady2 %diff lady1 lady2 7

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 8

9 %find. -name '*.c' -print %find. -user chang -ls %find. -mtime 14 -ls %find. -mtime 14 -ls -exec rm {} \; 9

10 10

11 11

12 12

13 13

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

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 15

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

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

18 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} 18

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 } 19

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

21 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 22

23 % tar -cvf tarfile. % tar -xvf tarfile % tar -rvf tarfile reverse.c % tar -cvf /dev/rst0 * 23

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 24

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 25


Download ppt "숙명여대 창병모 2011 가을 1. 파일 조작  filtering, sorting, comparing, searching for files 명령어 스케줄링  cron, at 텍스트 처리 프로그램  AWK 파일 보관 및 압축  archiving  tar, gzip."

Similar presentations


Ads by Google