User Tools

Site Tools


journal:spring2019:dtubbs2:week7

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
journal:spring2019:dtubbs2:week7 [2019/03/07 14:25]
dtubbs2
journal:spring2019:dtubbs2:week7 [2019/03/12 15:58] (current)
dtubbs2
Line 2: Line 2:
 ---- ----
 ====March 7, 2019==== ====March 7, 2019====
 +
 +**UPF1**
 +To find the options for each command use -h
 +
 +Precision is decimal value
 +
 +May need to specify to tool what precision is needed
 +
 +Make sure to make steps file that produces output without error
 +
 +Use ; to separate commands
 +--------------------------------------------
 +**Regular Expressions**
 +Share conceptual similarities to wildcards
 +
 +Use some of the same symbols
 +
 +Make sure to keep a distinction between regular expressions and wildcards
 +
 +Two Types of Regular Expressions:​
 +1) Basic Regular Expressions (Regex)
 +2) Extended Regex
 +
 +**Basic Regular Expressions:​**
 +^ will match start of line
 +$ will match end of line
 +\? will match 0 or 1 of the previous
 +. will match any single symbol
 +* will match 0 or more of the previous
 +[] (character class) will match any one of enclosed
 +[^ ] (inverted character class) do not match any one of enclosed
 +\< will match start of word
 +\> will match end of word
 +Will use mostly vim, grep, sed
 +
 +
 +**Extended Regex**
 ++ 1 or more of the previous (may need \)
 +| OR 
 +() group
 +\( \) regex group (used for remapping data)
 +
 +will use mostly vim, egrep, sed
 +--------------------------------------------
 +**What was done in class today**
 +cd /​usr/​share/​dict
 +
 +cat words | grep '​regex'​ | wc -l
 +
 +cat words | grep '​^.....$'​ | wc -l gives you number of words that have 5 characters
 +
 +cat words | grep '​^.[aeiouy].[aeiouy].$'​ | wc -l gives you the number of words that have 5 characters where the even numbered places are lowercase vowels ​
 +
 +cat words | grep '​^..[^rstlne].'​ | wc -l gives you the numbers of words that have 4 or more characters where the third letter is not r, s, t, l, n, or e
 +
 +cat words | grep '​^...*[mMg]...$'​ | wc -l gives you words that have 6 or more characters with m, M, or g somewhere in middle
 +
 +cat words | egrep '​(ed|ing)$'​ | wc -l would give you all the words that end with ed or ing
 +
 +cat words | egrep '​^(..)+$'​ | wc -l gives you all the even-symboled words 
 +
  
  
journal/spring2019/dtubbs2/week7.txt · Last modified: 2019/03/12 15:58 by dtubbs2