Table of Contents

Samantha's fall2014 Opus

The mad man's writings..

Introduction

I'm a web programming major. I have a work study at the school… during the breaks I work at burger king. It is not fun in any way.. I have a two year old. I hate new york state; the only thing keeping me here is the “free” tuition grants from TAP ect. I have roughly a total of 3 semesters left and im hoping it goes smoothly and fun from here on out.

UNIX/Linux Fundamentals Journal

its 09/02/2014 10:23PM .. I've just spent the past hour trying to clone my repository at home.. I finally got hg going, got used to those functions.. Then I get stuck on “abort: destination '~/src is not empty” then “mv src src.bak” wont work because no repository can be found cause .hg is missing they hint and it just doesn't make sense cause how could I have done any of this without downloading the mercurial package to begin with.. cant ask for help in the chat since I cant even get in. what a night.. and then Mr.Haas helped me solve the problem I never even had! everything turned out well..

UNIX/Linux Fundamentals Journal

09/30/2014 2:58… im pretty sure im not doing this right with the new entry. I thought I had to “edit the code of the page” and repeat the journal code to get a new section but someone said to do it this way so whatever.. highlight of the day: I'm stuck on this piped command in the puzzle box 2. it makes me feel really stupid because its seemingly perfect but I keep getting an error..

UNIX/Linux Fundamentals Journal

10/02/2014 6:09PM Today I learned how to actually use wild cards to my advantage.

UNIX/Linux Fundamentals Journal

This project was beautiful. I learned how to curse in different languages. and kyle is a wonderful help to me.

UNIX/Linux Fundamentals Journal

10/30/14 Today ive come extremely close to solving my grade the. the very end of this script is getting to me.

UNIX/Linux Fundamentals Journal

11/04/2014 4:30pm today we are talking about regular expressions (RegEx). ls doesn't work with regular expressions. We use them to form patterns to describe the text we are looking for.

regular expressions

  • • match any single character
  • * 0 or more of the previous
  • [] character class, match one of the enclosed
  • [^ ] do not match one of the enclosed
  • \< match start of word
  • \> match end of word
  • ^ match start of line
  • $ match end of line

extended RegEx

  • | or
  • ( ) grouping —> \( \) sed
  • + match/ or more of the previous

example: find in the system all 4 letter characters cat words| grep '^….$'| wc -l

example: find 4 chars or more ends with a 'g' cat words| grep '…[g]$'| wc -l

example: 3 or more, only lowercase cat words| grep '^[a-z][a-z][a-z][a-z]*$'| wc -l (the star at the end of the last [a-z] gets rid of the last guess)

example: all lines with 3 or more lower case vowels aeiouy cat words| grep '^.*[aeiouy].*[aeiouy].*[aeiouy].*$'| wc -l

egrep = grep+more fgrep → fast grep, no RegEx

example: all lines that end in lower case 'ed' OR 'ing' cat words| egrep 'ed$|ing$'| wc -l OR cat words| egrep '(ed|ing)$'| wc -l

next class will start Sed to re-arrange things and change patterns with regular expressions.

UNIX/Linux Fundamentals Journal

11/06/2014 4:10pm

Today we are talking in depth about the command Sed with RegEx.

find info for opus on even digit weeks. example: for single digit weeks.. status unix| grep 'opus'| grep 'week[02468]'

for double and single digit.. status unix| grep 'opus'| grep '[02468]entry$'

OR

status unix| grep 'opus'|egrep 'week([02468]|[0-9][02468])'

what Sed can do now.. get “entry for week 2 opus [1]

how.. s/ = search and replace .* = beginning of line followed by any number of characters \([01]\): its a RegEx grouping we just targeted.

status unix| grep 'opus'| sed 's/^.*\([01]\):\([a-z][a-z]*\):\(week\)\([0-9]\)\(.*\)$/\5 for\3\4\2 [\1]/g'

it all goes into grouping broken up and then replaces. see hard paper notes.

to find usernames starting with any of your initials ex: Victoria A Garfield is user vgarfield with userid 5933

command: getent passwd| grep '^[ss]'| sed 's/^\([ss][a-z0-9]*\):x:\([0-9][0-9][0-9][0-9]\):[0-9][0-9][0-9][0-9]:\([A-Z][a-z ,.A-Z]*\):\/home.*$/\3 is user \1 with user ID \2/g'

UNIX/Linux Fundamentals Journal

11/11/14

we filled out teacher evaluation forms. kyle decided to not take a class with me next semester. he sucks. i promised to write about my disappointment here. we talked about time zones/daylight savings.

Command line arguments

command: whereis status

now we are learning about status groups. breaking down the logic in running the unix status command.

we have ./myscript a b c $# - count of arguments “3” $* - all your agreements “a b c” $0 - script name $1 - “a” $2 - “b” $3 - “c”

how to type a safe variable “${1}” the double quotes keep it “safe”

if [-z “${1}”]; then (-z = null/empty string)

UNIX/Linux Fundamentals Journal

11/13/14

we talked about a command called: at..

example:

at 16:16 ls > out ctrl -d

then at 4:16 it will run the command ls > out. (scheduled jobs)

another command we talked about is cron.

ex: crontab -l to see if we have a cron tab.

ex: crontab -e

use absolute paths as much as possible because cron runs on a limited shell environment.

we examined previous written scripts and broke them down. # comments things out in scripts. we learned about a command called wget for pulling internet websites into terminal to find patterns.

UNIX/Linux Fundamentals Journal

11/18/2014

we got assigned a new project due some time after break, its undecided at the moment.

its a shell script

timeonline

-accept via command-line argument, or use input if not argument, the desired user name to process (for project).

EXAMPLE: ./timeonline wedge to run it properly. the second or use input if not arguement would be as soon as you entered the script, enter the user name.

-validate that the indicated user exists, proceed only if/when ok

-for each month of the semester determine…

  • number of login's for the month, in histogram form
  • total time spent on the system that the month in days, hours, mins
  • total logins for semester
  • total time for semester

VIM online help

http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html

for now…. lastlog| grep “ssmit133”

you get the specfic name but.. it needs to be a shell script

UNIX/Linux Fundamentals Journal

12/02/14 this was a horrible holiday season and break week. I didn't get everything I wanted done because life hates me.

but i have successfully got pretty decently far into the timeonline project on my own.. now its all a matter of writing the script without errors.

Portfolio

unix