Presentation is loading. Please wait.

Presentation is loading. Please wait.

CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Processing.

Similar presentations


Presentation on theme: "CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Processing."— Presentation transcript:

1 CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Processing

2 CIT 140: Introduction to ITSlide #2 Topics 1.Displaying files: cat, less, od, head, tail 2.File management: cp, mv, rm, ls, wc 3.Creating and appending 4.Concatenating files 5.Comparing files 6.Printing files

3 CIT 140: Introduction to ITSlide #3 Displaying Files 1.cat 2.less 3.od 4.head 5.tail

4 CIT 140: Introduction to ITSlide #4 Displaying files: cat cat [options] [file1 [file2 … ]] -e Displays $ at the end of each line. -n Print line numbers before each line. -t Displays tabs as ^I and formfeeds as ^L -v Display nonprintable characters, except for tab, newline, and formfeed. -vet Combines –v, -e, -t to display all nonprintable characters.

5 CIT 140: Introduction to ITSlide #5 Displaying files: less less [file1 [file2 … ]] h Displays help. q Quit. space Forward one page. return Forward one line. b Back one page. y Back one line. :n Next file. :p Previous file. / Search file.

6 CIT 140: Introduction to ITSlide #6 Displaying files: od od [options] [file1 [file2 … ]] -c Also display character values. -x Display numbers in hexadecimal. > file /kernel/genunix /kernel/genunix: ELF 32-bit MSB relocatable SPARC > od -c /kernel/genunix 0000000 177 E L F 001 002 001 \0 \0 \0 \0 \0 \0 \0 \0 0000020 \0 001 \0 002 \0 \0 \0 001 \0 004 246 230 \0 \0 \0 0000040 \0 033 ^ ` \0 \0 \0 \0 \0 4 \0 \0 \0 \0 \0 0000060 \0 017 \0 \n 235 343 277 240 310 006 004 244 020

7 CIT 140: Introduction to ITSlide #7 Displaying files: head and tail Display first/last 10 lines of file. head [-#] [file1 [file2 … ]] -# Display first # lines. tail [-#] [file1 [file2 … ]] -# Display last # lines. -f If data is appended to file, continue displaying new lines as they are added.

8 CIT 140: Introduction to ITSlide #8 File Management 1.Copying Files 2.Moving Files 3.Removing Files 4.File sizes

9 CIT 140: Introduction to ITSlide #9 Copying Files –cp [options] file1 file2 Options: -f, -i, -p, -r

10 CIT 140: Introduction to ITSlide #10 Copying files: cp cp [options] source destination cp [options] source1 source2 dest-dir -i Asks for confirmation if dest exists. -f Force copying if no write permission on destination. -p Preserve file metadata, such as ownership, permissions, and timestamp. -r Recursively copy subdirectories.

11 CIT 140: Introduction to ITSlide #11 Moving Files –mv [options] file1 file2 –mv [options] file-list directory

12 CIT 140: Introduction to ITSlide #12 Moving files: mv mv [options] source destination mv [options] source1 source2 dest-dir -i Asks for confirmation if dest exists. -f Force move regardless of permissions of destination.

13 CIT 140: Introduction to ITSlide #13 Removing Files Removing/ Deleting Files –rm [options] file-list

14 CIT 140: Introduction to ITSlide #14 Removing files: rm rm [options] target1 [target2, …] -i Asks for confirmation if dest exists. -f Force removal regardless of permissions of destination. -r Recursively remove subdirectories.

15 CIT 140: Introduction to ITSlide #15 File Size Determining File Size –ls –l wc [options] file-list

16 CIT 140: Introduction to ITSlide #16 Word count: wc wc [options] target1 [target2, …] -cCount bytes in file only. -lCount lines in file only. -wCount words in file only.

17 CIT 140: Introduction to ITSlide #17 File Processing 1.Creating and appending to files. 2.Concatenating files with cat. 3.Comparing files with diff. 4.Finding unique lines with uniq. 5.Printing files under BSD and SYSV UNIX.

18 CIT 140: Introduction to ITSlide #18 Creating and Appending to Files Creating files > cat >file Hello world Ctrl-d Appending to files > cat >> file Hello world line 2 Ctrl-d > cat file Hello world Hello world line 2

19 CIT 140: Introduction to ITSlide #19 Concatenating Files > cat >file1 This is file #1 > cat >file2 This is file #2 > cat file1 file2 >joinedfile > cat joinedfile This is file #1 This is file #2

20 CIT 140: Introduction to ITSlide #20 Comparing files: diff diff [options] oldfile newfile -bIgnore trailing blanks and treat other strings of blanks as equivalent. -cOutput contextual diff format. -eOutput ed script for converting oldfile to newfile. -iIgnore case in letter comparisons. -uOutput unified diff format.

21 CIT 140: Introduction to ITSlide #21 diff [options][file1][file2] Comparing Files with diff

22 CIT 140: Introduction to ITSlide #22 diff Example > diff Fall_Hours Spring_Hours 1c1 < Hours for Fall 2004 --- > Hours for Spring 2005 6a7 > 1:00 - 2:00 p.m. 9d9 < 3:00 - 4:00 p.m. 12,13d11 < 2:00 - 3:00 p.m. < 4:00 - 4:30 p.m.

23 CIT 140: Introduction to ITSlide #23 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! Removing Repeated Lines

24 CIT 140: Introduction to ITSlide #24 uniq uniq [options] input [output file] -cPrecedes each output line with a count of the number of times the line occurred in the input. -dSuppresses the writing of lines that are not repeated in the input. -uSuppresses the writing of lines that are repeated in the input.

25 CIT 140: Introduction to ITSlide #25 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!

26 CIT 140: Introduction to ITSlide #26 Printing Files

27 CIT 140: Introduction to ITSlide #27 Printing Files lp [options] file-list lpr [options] file-list

28 CIT 140: Introduction to ITSlide #28 lpq [options] Printing Files

29 CIT 140: Introduction to ITSlide #29 Canceling Your Print Job cancel [options] [printer] Printing Files

30 CIT 140: Introduction to ITSlide #30 Canceling Your Print Job (Contd) lprm [options][jobID-list][user(s)] Printing Files


Download ppt "CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Processing."

Similar presentations


Ads by Google