Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review for Exam 1 Exam 1 on June 24 CSC 3320.

Similar presentations


Presentation on theme: "Review for Exam 1 Exam 1 on June 24 CSC 3320."— Presentation transcript:

1 Review for Exam 1 Exam 1 on June 24 CSC 3320

2 cat (like concatenate), head, tail ls, cd mv, cp, rm mkdir, rmdir
pwd cat (like concatenate), head, tail ls, cd mv, cp, rm mkdir, rmdir file (determine file type), wc (word count) chmod Regular Expression grep, egrep, awk, sed at, crontab find, sort, tr, tar, ln, gzip, su, sudo CSC 3320

3 1) Create a sub-directory called “temp” in your home directory $ mkdir temp 2) Create a sub-directory called “subtemp” in “temp” $ mkdir ./temp/subtemp 3) Create file ex1.txt in “temp” and ex2.txt in “subtemp” $ cd temp $ cat > ex1.txt pwd ls ^D $ cd subtemp $ cat > ex2.txt Hello ex2! 4) Check file type and file's user access mode for file ex1.txt and ex2.txt $ cd ~ $ ls -l ./temp/ex1.txt CSC 3320

4 5) rename ex1.txt as ex1 and move it to home directory $ mv ~/temp/ex1.txt ~/ex1 6) change file pemissions of ex1, add user and group execute permission. $ chmod ug+x ~/ex1 7) copy file ex1 to your home directory $ cp ~/ex1 ~/ 8) copy the whole “temp” to ~/temp1 $ cp -r ~/temp ~/temp1 9) remove all files and sub-directories in “temp” $ rm -r ~/temp/* 10) remove “temp” $ rmdir ~/temp CSC 3320

5 Example Questions grant all exe files (extended name is exe) in the current directory or its subdirectories permission 777 create a hard link file1link for file1 display the hard link count for file1 and file1link remove file1 display the hard link count for file1link create a soft link file1 for file1link use ls –l display attributes of file1 and file1link CSC 3320

6 display the content of file1 use ls-l display file1
create a directory tartest in your home directory copy all files and directories in your home directory into tartest archive tartest to tartest.tar archive tartest to tartest1.tar with gzip option CSC 3320

7 display file size of tartest.tar and tartest1.tar
archive the current directory to current.tar create a directory tartest2 in your home directory extract tartest.tar copy tartest1.tar to tartest2 and extract tartest1.tar in tartest2 CSC 3320

8 Given the file ‘rolllist' format:
first-name last-name patherID register_way major credit CSC 3320

9 Example Questions (sort)
sort file sort it in reverse order sort on second field set “,” as separator, sort on second field set “.” As separator , sort on the third field by numeric order CSC 3320

10 Basic Regular Expression & Extended Regular Expression
Meta-characters in Basic Regular Expression ^ $ . * \( \) [ ] \{ \} \ vi, grep, sed accept basic regular expression. Meta-characters in Extended Regular Expression | ^ $ . * + ? ( ) [ ] { } \ egrep, grep –E, sed –E accept extended regular expression CSc 3320

11 Xabcdefghijklmnopqrstuv30 ^[A-Za-z]*[^,][A-Za-z]*$ AaBbCc,AaBbCc
Regular Expression Text Match? [A-Z] AB [0-9] 2 111* 11 [V|B]+ VB ^[A-Z][a-z]*3[0-5] Xabcdefghijklmnopqrstuv30 ^[A-Za-z]*[^,][A-Za-z]*$ AaBbCc,AaBbCc ^[A-Z]..*$ A bcd CSC 3320

12 Example Qustions (grep/egrep)
Given the file 'databook' (you can download it from website containing the lines of the following format: Type first-name last-name -address CSC 3320

13 Example Qustions (grep/egrep)
Do the following queries: Print all lines containing the string CS4520. b. Print all lines where the person's first name starts with J. c. Print all lines that contain .com d. Print all lines containing an upper-case letter, followed by four lower-case letters, a space and one uppercase letter. CSC 3320

14 Example Qustions (sed)
Use the file 'databook', do the following queries: a. Change Dumitru's name to Dima. b. Delete the first 3 line. c. Print all lines where the address d. Replace the line containing "CS2010" with "NULL NULL NULL NULL". e. Append the following new line at the end of the file. CS 3320 Xuan Guo CSC 3320

15 Example Qustions (awk)
a. Print all address. b. Print Dumitru's name and address. c. Change the type with the following rule: If line number modulo 3 is 1, the type field should be changed to CS4520. If line number modulo 3 is 2, the type field should be changed to CS2210. Otherwise keep the original type field. CSC 3320

16 Display the name of the owner of the shell Switch User to root
Write a command that archives and compresses the contents of a file, and writes the result to a new file. What is the corresponding command to extract it to produce the original file? Write a command to find files in a directory hierarchy (e.g. your home directory) that have the name pattern '*.txt" and compress them. Display the name of the owner of the shell Switch User to root Schedule jobs in file crontab.cron to be executed on a periodic basis. List the content of a registered crontab file. Unregister crontab.cron file CSC 3320

17 Schedule jobs in file at.csh to be executed 3 minutes later.
List the jobs which is scheduled by at Delete jobs of at.csh Print the line number and the content of file /etc/passwd from Line 10 to Line 50 Display the results of file “float” which covert all upper-case characters in file float into lower-case. CSC 3320


Download ppt "Review for Exam 1 Exam 1 on June 24 CSC 3320."

Similar presentations


Ads by Google