Præsentation er lastning. Vent venligst

Præsentation er lastning. Vent venligst

1 Course process: – Read, solve exercises before lecture – Lecture: questions, examples not in the notes, perhaps a summary of the reading, exercises Lecture.

Lignende præsentationer


Præsentationer af emnet: "1 Course process: – Read, solve exercises before lecture – Lecture: questions, examples not in the notes, perhaps a summary of the reading, exercises Lecture."— Præsentationens transcript:

1 1 Course process: – Read, solve exercises before lecture – Lecture: questions, examples not in the notes, perhaps a summary of the reading, exercises Lecture times 2x2 hrs? – Tuesdays 10-12 impossible Today: Unix intro, Python’s dynamic interpreter

2 2 Directory structure of ~chili/PBI ~chili PBI ProgramExamples Exercises Mail FromCourseNotesSolutions SlidesNotes

3 3 Week1 threonine:~% cd ~/PBI/ProgramExamples/ threonine:~...ProgramExamples% mkdir Week1 threonine:~...ProgramExamples% ls FromCourseNotes integer_addition.py jakobs.txt Week1 ~chili PBI ProgramExamples Exercises Mail FromCourseNotes Solutions SlidesNotes

4 4 Week1 threonine:~% cd ~/PBI/ProgramExamples/ threonine:~...ProgramExamples% mkdir Week1 threonine:~...ProgramExamples% ls FromCourseNotes integer_addition.py jakobs.txt Week1 threonine:~...ProgramExamples% cd Week1/ threonine:~...Week1% cp../jakobs.txt. threonine:~...Week1% ls jakobs.txt threonine:~...Week1% more jakobs.txt ProgramExamples FromCourseNotes

5 5 AU employees with ‘Jakob' in their name 8942 2296 Anne Chresteria Jakobsen, u.ass. Klassisk Filologi (1414-414) 8942 4454 Benjamin Jakobsen, studerende bentoft@daimi.au.dk Datalogisk Institut (5128-155) 8942 3573 Birgitte Jakobsen, assistent bij@phys.au.dk Institut for Fysik og Astronomi (1520-120) 8942 6863 Bo Bjerre Jakobsen, chefkonsulent bbj@adm.au.dk Erhvervskontakten (1444-022) 8942 4037 Connie Jakobsen, sekretr cjakobsen@odont.au.dk Afdeling for Ortodonti (1611-224) 8942 4920 Dorte Moe Jakobsen, fuldmgtig, cand.jur. dmj@adm.au.dk Psykologisk Institut (1481-433) 8942 1530 Dorte Moe Jakobsen, fuldmgtig, cand.jur. dmj@adm.au.dk Det Samfundsvidenskabelige Fakultetssekretariat (1327-316) 8942 1780 Elin Jakobsen, laborant elj@microbiology.au.dk Institut for Medicinsk Mikrobiologi og Immunologi (1242-518) 8942 3750 Hanne Jakobsen, Laborant hj@phys.au.dk Institut for Fysik og Astr jakobs.txt lines 1-9/68 11%

6 6 Find pattern ‘Fredslund’ using grep threonine:~...Week1% grep fredslund jakobs.txt (no result – grep is case-sensitive) threonine:~...Week1% grep Fredslund jakobs.txt 8942 3125 Jakob Fredslund, forskningsadjunkt chili@daimi.au.dk Center for Bioinformatik (1090-115) (all lines in jakobs.txt containing the pattern Fredslund )

7 7 Using sort [..] 8942 6555 Jakob Ilum Steensig, lektor, ph.d., studieleder linjs@hum.au.dk Afdeling for Lingvistik (1410-342) 8942 6863 Bo Bjerre Jakobsen, chefkonsulent bbj@adm.au.dk Erhvervskontakten (1444-022) 8942 9247 Jakob Isak Nielsen, ph.d.-studerende jakobisak@imv.au.dk Institut for Informations- og Medievidenskab (5347-231) 8942 9252 Jakob Linaa Jensen, adjunkt. cand.scient.pol, ph.d linaa@imv.au.dk Institut for Informations- og Medievidenskab (5347-227) 8942 9291 Thomas Jakobsen, programmør mas@daimi.au.dk Datalogisk Institut (5341-213) 8942 9363 Jakob Roland Andersen, OOVM jakob.andersen@oovm.com Mobil: 2962 1226 Alexandra Instituttet A/S (5346-224) threonine:~...Week1% cat jakobs.txt | sort Note: each name followed by a comma

8 8 Using cut [..] 8942 5402 Jakob Munk Højte 8942 5423 Mads Leth Jakobsen 8942 5631 Jakob Illeborg Pagter 8942 5674 Jakob Eyvind Bardram 8942 5677 Jakob Langdal Jensen 8942 6167 Jakob Bønløkke 8942 6510 Jakob Stougaard-Nielsen 8942 6555 Jakob Ilum Steensig 8942 6863 Bo Bjerre Jakobsen 8942 9247 Jakob Isak Nielsen 8942 9252 Jakob Linaa Jensen 8942 9291 Thomas Jakobsen 8942 9363 Jakob Roland Andersen …Week1% cat jakobs.txt | sort | cut -d ',' -f1

9 9 Using redirect …Week1% cat jakobs.txt | sort | cut -d ',' -f1 > names_and_numbers.txt …Week1% ls –l total 12 -rw-r--r-- 1 chili users 7594 Oct 20 14:28 jakobs.txt -rw-r--r-- 1 chili users 1982 Oct 20 14:56 names_and_numbers.txt

10 10 Permissions …Week1% cat jakobs.txt | sort | cut -d ',' -f1 > names_and_numbers.txt …Week1% ls –l total 12 -rw-r--r-- 1 chili users 7594 Oct 20 14:28 jakobs.txt -rw-r--r-- 1 chili users 1982 Oct 20 14:56 names_and_numbers.txt -rw-r-- d for directory usergroupall user group all

11 11 Using chmod …Week1% chmod a-r * …Week1% ls -l total 12 --w------- 1 chili users 7594 Oct 20 14:28 jakobs.txt --w------- 1 chili users 1982 Oct 20 14:56 names_and_numbers.txt …Week1% chmod u+r * …Week1% ls -l total 12 -rw------- 1 chili users 7594 Oct 20 14:28 jakobs.txt -rw------- 1 chili users 1982 Oct 20 14:56 names_and_numbers.txt …Week1% chmod a+rx names_and_numbers.txt …Week1% ls -l total 12 -rw------- 1 chili users 7594 Oct 20 14:28 jakobs.txt -rwxr-xr-x 1 chili users 1982 Oct 20 14:56 names_and_numbers.txt

12 12 Python's dynamic interpreter threonine:~...Week1% python Python 2.3.4 (#1, Feb 2 2005, 12:11:53) [GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> a = 7 >>> b = 9 >>> a*b 63 >>> def f(x): return x*x*x*x... >>> f(3) 81

13 13 dir(), importing math functions >>> dir() ['__builtins__', '__doc__', '__name__'] >>> from math import * >>> dir() ['__builtins__', '__doc__', '__name__', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp', 'log', 'log10', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh']

14 14 Function help() >>> help(pow) Help on built-in function pow: pow(...) pow(x,y) Return x**y (x to the power of y).

15 15 Redefining the function f >>> def f(x): return pow(x, 4)... >>> f(3) 81.0 >>> f(4) 256.0 ( pow regards its input as floating point numbers, not integers)

16 16.. on to the exercises


Download ppt "1 Course process: – Read, solve exercises before lecture – Lecture: questions, examples not in the notes, perhaps a summary of the reading, exercises Lecture."

Lignende præsentationer


Annoncer fra Google