User Tools

Site Tools


notes:unix:spring2024:classnotes

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:unix:spring2024:classnotes [2024/03/12 14:10] – [Tuesday] cgrant9notes:unix:spring2024:classnotes [2024/04/16 13:19] (current) cgrant9
Line 1: Line 1:
 ======UNIX class notes====== ======UNIX class notes======
 +[[#Week 5|In Depth VI Notes]]
 +
 +[[#Cleaned VI Notes|Basic VI Notes]]
 +
 +[[#Week 9|REGEX's]]
  
 =====Week 1===== =====Week 1=====
 +<fs xx-large>Welcome to the best class you have ever taken</fs>
 +
 +This page includes some notes, typically major things, from each class session
  
 +Please add notes whenever you can = )
 =====Week 2===== =====Week 2=====
 *Re-went over group and pwd command *Re-went over group and pwd command
Line 85: Line 94:
 Insert commands (put you in insert mode): Insert commands (put you in insert mode):
  
-i types before the cursor +   i types before the cursor 
- +   * a types after the cursor 
-a types after the cursor +   * I inserts at the start of the line 
- +   * A appends at the end of the line 
-I inserts at the start of the line +   * o insert on new line below 
- +   * O insert on new line above
-A appends at the end of the line +
- +
-o insert on new line below +
- +
-O insert on new line above +
- +
  
 To get out of insert mode press the esc key To get out of insert mode press the esc key
- 
- 
  
 Navigation commands:  Navigation commands: 
- +   h moves left one character 
-h moves left one character +   * l moves right one character 
- +   * j moves down one line 
-l moves right one character +   * k moves up one line 
- +   * w moves forward by word (seperated values) 
-j moves down one line +   * W moves forward by word chunk (seperated by spaces specifically) 
- +   * b moves backwards by one word (seperated values) 
-k moves up one line +   * B moves backwards by one word chunk (seperated by spaces specifically) 
- +   * { moves backwards a paragraph 
-w moves forward by word (seperated values) +   * } moves forwards a paragraph 
- +   * #G move you to the line of the given number 
-W moves forward by word chunk (seperated by spaces specifically) +   * #gg is the same as #G 
- +   * $G takes you to the last line in the file 
-b moves backwards by one word (seperated values) +(prefixing the navigation commands with a number moves by the number of characters, ie 6h moves left 6 characters)
- +
-B moves backwards by one word chunk (seperated by spaces specifically) +
- +
-{ moves backwards a paragraph +
- +
-} moves forwards a paragraph +
- +
-#G move you to the line of the given number +
- +
-#gg is the same as #G +
- +
-$G takes you to the last line in the file +
- +
-prefixing the navigation commands with a number moves by the number of characters, ie 6h moves left 6 characters +
- +
- +
 If you want to open Vim on a certain line you can type vim +line# textfilename If you want to open Vim on a certain line you can type vim +line# textfilename
  
Line 140: Line 123:
  
 Manipulation commands: Manipulation commands:
- +   x is similar to the delete key by character 
-x is similar to the delete key by character +   * X is similar to backspace 
- +   * dW delete by word forward 
-X is similar to backspace +   * dB delete by word backward 
- +   * d{ delete by paragraph backwards 
-dW delete by word forward +   * d} delete by paragraph forwards 
- +   * dd delete line 
-dB delete by word backward +   * p paste 
- +   * P paste 
-d{ delete by paragraph backwards +   * y copies, has yw, y{, yy 
- +   * c is change, which is a delete and insert command as one, has cw, cb, c{, c}, c^, c$ (carat is start of file, $ is end of file so c^ is from here to beginning, c$ is from here to end) 
-d} delete by paragraph forwards +   * . repeats last manipulation command 
- +
-dd delete line +
- +
-p paste +
- +
-P paste +
- +
-y copies, has yw, y{, yy +
- +
-c is change, which is a delete and insert command as one, has cw, cb, c{, c}, c^, c$ (carat is start of file, $ is end  +
-of file so c^ is from her to beginning, c$ is from here to end) +
- +
-. repeats last manipulation command  +
- +
  
 Exit commands Exit commands
- +   :w writes, if no file name is given you need to give it a file name, so :w filename 
-:w writes, if no file name is given you need to give it a file name, so :w filename +   * :q! quits without saving 
- +   * :wq writes and quits 
-:q! quits without saving +   * ZZ saves and quits, checks if there is enough space in the file system to save. This is technically safer than using wq only because wq does not check for space and if there was ever not enough memory, then whatever you tried to save would be gone.
- +
-:wq writes and quits +
- +
-ZZ saves and quits, checks if there is enough space in the file system to save. This is technically safer than using wq only because wq does not check for space and if there was ever not enough memory, then whatever you tried to save would be gone.+
  
 You can see why vi is bimoded because we can switch between two different modes (command and insert). You can see why vi is bimoded because we can switch between two different modes (command and insert).
Line 183: Line 147:
 =====Thursday===== =====Thursday=====
 More basics in Vi More basics in Vi
- +   ~ toggles the case of letter, ie if cursor is on n ~ changes it 2 N 
-~ toggles the case of letter, ie if cursor is on n ~ changes it 2 N +   * u undoes what was just done 
- +   * q records your Vi experience 
-u undoes what was just done +   * / search keyword, when followed by n goes to next, when followed by N goes to previous 
- +   * s substitutes character / deletes character and places in insert mode 
-q records your Vi experience +   * S substitutes line / deletes line and places in insert mode 
- +   * ^ moves to beginning of line 
-/ search keyword, when followed by n goes to next, when followed by N goes to previous +   * $ moves to end of line
- +
-s substitutes character / deletes character and places in insert mode +
- +
-S substitutes line / deletes line and places in insert mode +
- +
-^ moves to beginning of line +
- +
-$ moves to end of line+
  
 --Extended VI command mode-- --Extended VI command mode--
  
 to enter type a colon : to enter type a colon :
- +   :#co# copies the first numbered line to the 2nd numbered line 
-:#co# copies the first numbered line to the 2nd numbered line +   * :#,#co$ copies range of lines to end 
- +   * :#m# moves numbered line to numbered line 
-:#,#co$ copies range of lines to end +   * :set number   enables line numbers 
- +   * :set nonumber   disables line numbers 
-:#m# moves numbered line to numbered line +   * :syntax on  turns on syntax coloring 
- +   * :syn on  same as syntax on 
-:set number   enables line numbers +   * :set tabstop=#  changes length of tabs 
- +   * :set shiftwidth=# 
-:set nonumber   disables line numbers +   * :set cursorline  puts a line where your cursor is horizontally 
- +   * :set cursorcolumn  puts a line where your cursor is vertically 
-:syntax on  turns on syntax coloring +   * :set smartindent   adds smart indents in curley braces 
- +   * :set scrolloff=#   sets distance where  
-:syn on  same as syntax on +   * :colorscheme changes the color of your vim 
- +   * :%s/word1/word2/ search and replace, searches for word1 and replaces with word2
-:set tabstop=#  changes length of tabs +
- +
-:set shiftwidth=# +
- +
-:set cursorline  puts a line where your cursor is horizontally +
- +
-:set cursorcolumn  puts a line where your cursor is vertically +
- +
-:set smartindent   adds smart indents in curley braces +
- +
-:set scrolloff=#   sets distance where  +
- +
-:colorscheme changes the color of your vim +
- +
-:%s/word1/word2/ search and replace, searches for word1 and replaces with word2+
  
 You can edit your default settings in Vim by adding to your ~/.vimrc file You can edit your default settings in Vim by adding to your ~/.vimrc file
Line 282: Line 223:
 =====Tuesday===== =====Tuesday=====
 We did our first base 9 puzzle We did our first base 9 puzzle
 +
 More modification to our script, now it lists out time in days, hours and minutes More modification to our script, now it lists out time in days, hours and minutes
 +
 The script now accepts arguments to sort by most logins or most time The script now accepts arguments to sort by most logins or most time
 +
 +There are many ways to pass a script an argument, the way we did is by giving a variable the arguments defined by ${#}, ie the first argument would be ${1}
 +
 =====Thursday===== =====Thursday=====
 ---------------- ----------------
 +The dawn of the final puzzle box is upon us, enjoy its brain expanding power
 +
 +Field trip, went to the binary clock, which runs on an older gen raspberry pi
 +
 +We found multiple ways to reset/backup an sd card
 +
 +Field trip resulted in many great discussions pertaining to engineering and the limitations of creating technology, including software
 =====Week 8===== =====Week 8=====
 ---------------- ----------------
 =====Tuesday===== =====Tuesday=====
 +No class, free day for experimentation/completing assignments
 +
 =====Thursday===== =====Thursday=====
 ---------------- ----------------
 +No class, free day for experimentation/completing assignments
 =====Week 9===== =====Week 9=====
 ---------------- ----------------
 =====Tuesday===== =====Tuesday=====
 +Virtual class session day
 +
 +Started discussing wpa0
 +
 +in a man page, or vi, or a less pager you can use a forward slash to search for something
 +
 +Remember wildcards are specifically filenames, regex's are for text
 +
 +REGULAR EXPRESSIONS!!!!!!!
 +  
 +Basic REGEX (in Unix)
 +   * .  match any symbol (similar to ? in wildcards)
 +   * *  match zero or more of the previous (similar, but different to * in wildcards)
 +   * ^  match start of line
 +   * $  match end of line
 +   * \< match start of word
 +   * \> match end of word
 +   * [ ] character class; match any one of enclsed (similar to use as wildcard)
 +   * [^ ] inverted character class; do not match any of enclosed (similar to use as wildcard)
 +
 +Extended REGEX
 +   * + match 1 or more of the previous
 +   * | logical or
 +   * ( ) group together
 +   * \( \) REGEX group
 +   * ? match previous item at most once (0-1)
 +   * {n} match previous item exactly n times ie " {3}" looks for exactly 3 spaces
 +   * {n,} match previous n or more times
 +   * {,m} match previous at most m times
 +   * {n,m} match previous at least n, but no more than m times
 +
 +3 types of grep used to be used based on what REGEX's you need
 +   *fgrep - fast grep; no REGEX use
 +   *grep - regular grep; basic REGEX use
 +   *egrep - extended grep; extended REGEX use
 +
 +you can still use extended regex with a regular grep, but they need to be preceded by a \, ie a grep "\?" should work like egrep "?"
 +
 +diff - a command that can show differences in files, assuming they are sorted
 +
 =====Thursday===== =====Thursday=====
 ---------------- ----------------
-=====Week 10=====+No class, free day to experiment and work on projects 
 +=====Weeks 10-14=====
 ---------------- ----------------
-=====Tuesday===== +Mostly given time to work on projects, the last major discussion was Regex's, and a quick base 11 pct 
-=====Thursday===== +Work on your EoCE  
----------------- + 
-=====Week 11===== + 
----------------- +=====Cleaned VI Notes===== 
-=====Tuesday===== +<fs 80%>(Images courtesy of Corey)</fs> 
-=====Thursday===== +-------------------------------------------- 
----------------- +{{:notes:unix:spring2024:vi1.png?400|}} 
-=====Week 12===== +{{:notes:unix:spring2024:vi2.png?400|}} 
----------------- + 
-=====Tuesday===== +There currently is more above, check Week 5 for a more complete list
-=====Thursday===== +
----------------- +
-=====Week 13===== +
----------------- +
-=====Tuesday===== +
-=====Thursday===== +
----------------- +
-=====Week 14===== +
----------------- +
-=====Tuesday===== +
-=====Thursday=====+
  
notes/unix/spring2024/classnotes.1710267034.txt.gz · Last modified: 2024/03/12 14:10 by cgrant9