Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen.

Similar presentations


Presentation on theme: "Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen."— Presentation transcript:

1 Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

2 Last time ssh –l my_name babel.colorado.edu (connect with babel) pwd (where am I?) ls (what’s here?) cd (I want to go somewhere else) mkdir

3 Switches: Unix adverbs options that you specify ls –l : long listings ls –a : show hidden files, too ls –t : sort by time ls –lat : show all files, in long format, sorted by time

4 Switches

5 Arguments: objects No argument allowed: –pwd Argument required: –mkdir [kev@compbio kev]$ mkdir mkdir: too few arguments Try `mkdir --help' for more information. [kev@compbio kev]$

6 Arguments Argument(s) optional: –cd (no arg—what happens?) –cd.. (arg is..—what happens?)

7 Arguments Argument(s) optional: –cd (no arg—what happens?) –cd.. (arg is..—what happens?) –ls (no arg—what happens?) –ls.cshrc (arg is.cshrc)

8 Arguments Argument(s) optional: –cd (no arg—what happens?) –cd.. (arg is..—what happens?) –ls (no arg—what happens?) –ls.cshrc (arg is.cshrc) babel>ls.cshrc.cshrc babel>ls i_like_my_dog i_like_my_dog not found File named.cshrc exists File named i_like_my_dog doesn’t exist

9 Wildcards Underspecified objects Syntax: combine with any amount of the name of an argument Examples: ls ling* ls linguistics* ls *linguistics

10 Wildcards Underspecified objects Syntax: combine with any amount of the name of an argument Examples: ls ling* ls linguistics* ls *linguistics Semantics: “allow zero or more of any character(s) here” Show me: ling linguist linguistics

11 babel>pwd /home/kev/demo_wildcards babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics

12 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls ling ling babel>ls ling* ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists

13 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls linguist*

14 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls linguist* linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists

15 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls *linguistics

16 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls *linguistics linguistics psycholinguistics sociolinguistics

17 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls *ics

18 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls *ics linguistic_phonetics linguistics phonetics psycholinguistics sociolinguistics

19 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls *and*

20 babel>ls ling linguistic_anthropology linguistic_phonetics linguistics linguistics_and_the_law linguists morphology phonetics psycholinguistics sociolinguistics babel>ls *and* linguistics_and_the_law

21 Switches + Arguments You can combine them. –Switches come first. ls –lt li* “List everything that starts with li followed by zero or more of any other character… …show me the “long” version… …and arrange them by “time.”

22 Two ways of specifying location Relative: walk out the door. Take stairs to first floor. Exit building from east. Take 36 to I-70. Get off at Vasquez exit. Merge onto Colorado. Turn left onto 23 rd. Turn right onto Krameria. Go to next block. Go to house on southwest corner.

23 Two ways of specifying location Relative: walk out the door. Take stairs to first floor. Exit building from east. Take 36 to I-70. Get off at Vasquez exit. Merge onto Colorado. Turn left onto 23 rd. Turn right onto Krameria. Go to next block. Go to house on southwest corner. Absolute: Go to 2089 Krameria St., Denver, CO.

24 I’m in /home/kev, and I want to see the contents of /home Using relative path: ls.. Using absolute path: ls /home

25 I’m in /home/kev, and I want to see the contents of /home/jurafsky Using relative path: ls../jurafsky Using absolute path: ls /home/jurafsky

26 More things you can do with files View their contents Copy Rename/move them Delete them Count contents Compare their contents Please open a terminal and ssh to babel

27 Viewing file contents The whole thing at once The whole thing, a bit at a time Just part of it

28 Viewing file contents The whole thing at once cat filename Example: cd ls -a cat.cshrc

29 Viewing file contents The whole thing, a bit at a time more filename Example: ls /corpora/celex/english more /corpora/celex/english/README

30 Viewing file contents Just some of it (just the beginning) head filename head –number_of_lines filename Example: head /corpora/celex/english/README head –20 /corpora/celex/english/README

31 Viewing file contents Just some of it (just the end) tail filename tail –number_of_lines filename Example: head /corpora/celex/english/README head –20 /corpora/celex/english/README

32 Copying: cp A ditransitive verb cp original_file new_file Example: cd cp.cshrc.cshrc_bak

33 Caution: no guardrails touch junk cat junk cp.cshrc junk cat junk

34 Moving/renaming: mv A ditransitive verb mv original_file new_file Example 1: cd ls mv.cshrc.bak.cshrc_bak01

35 Moving/renaming: mv A ditransitive verb mv original_file new_file Example 1: cd ls mv.cshrc.bak.cshrc_bak01 Renames the file

36 Moving/renaming: mv A ditransitive verb mv original_file new_file Example 2: cd ling5200 ls mv../junk.

37 Moving/renaming: mv A ditransitive verb mv original_file new_file Example 2: cd ling5200 ls mv../junk. Moves the file from parent to current directory

38 Moving/renaming: mv A ditransitive verb mv original_file new_file Example 3: cd ling5200 ls mv../junk mango

39 Moving/renaming: mv A ditransitive verb mv original_file new_file Example 3: cd ling5200 ls mv../junk mango Moves from parent to current directory and changes name

40 man pages Unix’s help facility Syntax: man command_name E.g.: man cp To see more, hit the spacebar

41 Comparing files: diff A ditransitive verb diff one_file another_file Example 3: cd ling5200 diff../junk mango touch junk diff junk mango

42 man pages Name Synopsis of syntax Description Options

43 man pages

44 Remember you said you’d like cp to ask you before it blew away your file? Consult the man page for cp Make a back-up copy of your.cshrc file ( cp.cshrc.cshrc.bk01 ) Open it in a text editor ( emacs.cshrc ) Create an alias for cp Ctrl-XS Ctrl-X Ctrl-C Tell Unix about your new alias ( source.cshrc )

45 Interlude

46 HW1 1.Well?

47 HW1 #1 “He has all of the primary facts that he needs, in the form of a corpus of approximately one zillion running words, and he sees his job as that of deriving secondary facts from his primary facts. At the moment he is busy determining the relative frequencies of the eleven parts of speech as the first word of a sentence versus the second word of a sentence.” --Fillmore

48 HW1 #1 He sits in a deep soft armchair, with his eyes closed and his hands clasped behind his head. Once in a while he opens his eyes, sits up abruptly shouting, ‘Wow, what a neat fact!’, grabs his pencil, and writes something down…having come still no closer to knowing what language is really like.” --Fillmore

49 HW1 #1 Why should I think anything you tell me is true? Why should I think anything you tell me is interesting?

50 HW1 #1 “They [take] this to be science, very genuinely and very sadly.” --Postal

51 HW1 #1 Rationalism as theory, yes—method, no (Sampson) “I don’t think there can be any corpora, however large, that contain information about all of the areas of English lexicon and grammar that I want to explore…[but] every corpus I have had the chance to examine, however small, has taught me facts I couldn’t imagine finding out any other way.” (Fillmore)

52 HW1 5. ssh

53 Some important Unix concepts Redirection Security/permissions Environment

54 Piping and redirection Piping: sending the output of one command to another command as its input cat.cshrc | wc Use the output of that… …as the input for this

55 Piping and redirection ls –l /corpora2 ls –l /corpora2 | head ls –l /corpora2 | head -5

56 Piping and redirection Redirection: sending output someplace other than to your screen ls –l /corpora2 > corpora2_contents Put the output of this command… …into this file

57 Piping and redirection If the file doesn’t already exist… If the file does already exist… >> cat.cshrc > junk ls –lt /corpora2 >> junk No space!

58 LINGUIST-L Position Description: Primary responsibility is the creation and maintenance of linguistic test data. This involves analyzing a set of sentences and generating the expected linguistic analysis based on the specification. Other responsibilities include evaluating linguistic coverage, reporting accuracy, generating linguistic bugs, and tracking regression of the products and technology.

59 Security passwd : change your password –no real words –mix case (E.g. M!nkeY, not m!nkey) –mix letters, other symbols (@rm3n!an) –change frequently –nothing obvious (chomsky, phonology, birthday, cat’s name) –DON’T email them

60 Security

61

62

63 Permissions FileDirectory r view copy list contents w change delete create delete x executecd into

64 Security Permissions “-” means file “d” means directory you (user)

65 Security Permissions “-” means file “d” means directory

66 Security Permissions “-” means file “d” means directory you (user) group

67 Security Permissions “-” means file “d” means directory you (user) groupothers (world)

68 Changing permissions Easy way: chmod who+/-what filename Who: –u : user (you) –g : group –o : other (world)

69 Changing permissions Easy way: chmod who+/-what filename Who: –u : user (you) –g : group –o : other (world) What: –r : read –w : write –x : execute

70 Changing permissions Easy way: chmod who+/-what filename Who: –u : user (you) –g : group –o : other (world) What: –r : read –w : write –x : execute chmod u+x helloWorld.pl

71 Changing permissions Easy way: chmod who+/-what filename Who: –u : user (you) –g : group –o : other (world) What: –r : read –w : write –x : execute chmod u+x helloWorld.pl chmod go-w helloWorld.pl

72 Changing permissions Medium: chmod u=rwx,g=r,o=r hello.pl Who: –u : user (you) –g : group –o : other (world) What: –r : read –w : write –x : execute chmod u+x helloWorld.pl chmod go-w helloWorld.pl

73 Changing permissions Hard: chmod 744 helloWorld.pl Who: –First digit: user (you) –Second digit: group –Third digit: other (world) What: –4 : read –2 : write –1 : execute –0 : nothing chmod u+x helloWorld.pl chmod go-w helloWorld.pl

74 Environment uname echo $SHELL echo $PATH setenv setenv DUMMY_VARIABLE melgibsonsux echo $DUMMY_VARIABLE


Download ppt "Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen."

Similar presentations


Ads by Google