User Tools

Site Tools


journal:spring2019:jsamson3:week3

Differences

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

Link to this comparison view

journal:spring2019:jsamson3:week3 [2019/01/31 08:33]
127.0.0.1 external edit
journal:spring2019:jsamson3:week3 [2019/02/06 20:51] (current)
jsamson3 [February 06, 2019]
Line 1: Line 1:
 =====unix week3===== =====unix week3=====
 ---- ----
-====MONTH DayYEAR====+====February 062019====
  
-Filler textyour entry goes here; remove ​this line to receive full credit.+This week I learned a good amount about Unix. With the readings, lectures by Matt Haas, and the pbx0 project: the my command vocabulary has grown a good amount. However, before I go on and tell you all the **fun** and **exciting** commands I've learned, I will start off by telling you a thing or who about what I've learned from class. 
 + 
 + 
 +====There are 3 Different Styles of Quotes in Unix==== 
 + 
 +Quote #1: **"​**Half Quotes**"​** <These allow for expansion, especially variable expansion! 
 + 
 +Quote #2: **'​**Full Quotes**'​** <- These are literal quotes and do no expansion. 
 + 
 +Quote #3: **`**Back Quotes/Back Tick**`** //(or)// **$(**Back Quotes/Back Tick**)** <- There are used for command expansion. 
 + 
 +====Command Expansion Exercise==== 
 +During class we used the different quotes to make a variable which stated a sentence which also had a variable in it. 
 + 
 +**BUT WHAT IS A VARIABLE?** -> Variables are used for declaring (setting) and accessing (expanding) something. We can use variables to make life easier.  
 + 
 +During ​this exercise we wanted ​to create a variable which, when using the echo command, would say something. We wanted it to say "There are **X** users online at the moment"​. So, we first need to think of how we can make **X** happen. Which using the following we were able to make a command that, when used with echo, would just display the number of users on at the moment. <WRAP warning> **numlogins=$(/​usr/​bin/​who | wc -l)**</​WRAP>​ 
 +//​numlogins//​ <- Represents what we want to name our variable.  
 + 
 +// /​usr/​bin/​who//​ <- Represents where the *who* command is located 
 + 
 +//wc -l// <- Represents how the command will count the number of users online and list the number so we can see it. 
 + 
 +**REMEMBER** we are using back quotes because we are dealing with a command. 
 + 
 +Now that we created that variable, when using the echo command with $numlogins: it should display the number of users online at the current moment. ->(echo $numlogins)<​- 
 + 
 +But, we want a message; not just a number!. So time to create that now. The following will do that for you. 
 +<WRAP warning> **whoisthere=$ "There are $numlogins users on at the moment."​** </​WRAP>​ 
 + 
 +//​whoisthere//​ = Represents what we want to name our variable. 
 +By using half quotes we are able to capture the message we want to have displayed, and we replayed the **X** from earlier with our variable we just made. So, by entering (echo $whoisthere) it will display the message we wanted all along. 
 + 
 +====Wildcard Characters==== 
 +**?** <-Match one of any character. 
 + 
 +***** Will match zero or more of any characters. 
 + 
 +**[]** <- Match one of any enclosed character(s) (CHARACTERCLASS) 
 + 
 +**[^]** <- So not match one of any enclosed character(s) (INVERTED CHARACTERCLASS) 
 + 
 +====COMMANDS==== 
 + 
 +sed <- strean editor for filtering and transforming text. 
 + 
 +wc <- counts 
 + 
 +wc -l <- count lines 
 + 
 +sort -n <- sorts based on starting number in a line.
  
journal/spring2019/jsamson3/week3.txt · Last modified: 2019/02/06 20:51 by jsamson3