+ - 0:00:00
Notes for current slide
Notes for next slide

Unix II

1 / 13

Big News (1 of 3)

Marcus M. Darden, Jr.

  • New edition addition guy... Marcus, Jr.
  • Big & Fast
2 / 13

Big News (2 of 3)

  • C4CS Course Creator
  • Towner Prize (Outstanding GSI) Winner
  • Mr. Chez Betty
  • All around Great Person
3 / 13

Big News (3 of 3)

  • Git II Lecturer: IA Matt Terwilliger
  • Personal redemption
  • #SEEYOUINCLASS
4 / 13

Administrative

5 / 13

Regex/Regexp

What is it?

  • 99 Problems
  • All the "Big" tools use it
  • Try out
    • www.regular-expressions.info
    • www.regexr.com
  • Endless amusement during live demos
6 / 13

Regex/Regexp

What is it?

  • 99 Problems
  • All the "Big" tools use it
  • Try out
    • www.regular-expressions.info
    • www.regexr.com
  • Endless amusement during live demos

The Basics

  • Special Characters \^$.|?*+()[]{}
  • Character classes [<chars>]
  • Shorthand classes \<char> and [[:class:]]
  • Anchors
  • Alternation
  • Repetition
  • Greedy & Lazy
  • Grouping
  • Backreferencing
7 / 13

Working on data by line

Get it out there

  • cat
  • echo
  • head
  • tail

Big Tools

  • grep (g/re/p)
  • sed
  • awk
8 / 13

Other Tools

  • cut
  • tee
  • tr
  • sort
  • uniq
  • diff
  • comm
9 / 13

3 Ways to get/use input/output

  1. Use pipes (|) to connect multiple commands
  2. Use redirection to read/write files
  3. Use a subshell $() to assign to variables
10 / 13

File Redirection

File descriptors, name and number

  • 0: Standard Input (stdin, cin)
  • 1: Standard Output (stdout, cout)
  • 2: Standard Error (stderr, cerr)

Operators

  • < send file as input
  • > send output to file (create/overwrite)
  • >> append output to file (create/preserve)
  • >& merge output
  • <& merge input
  • << "Here Document"
11 / 13

Scripts

  • Just Do It!
    • history
  • Shebang, Hashbang, #!
  • Get that money...
    • $0 current script
    • $n script args 1, 2, 3...
    • $# number of args
    • $* and $@ quoted args
    • $? the previous return value
  • Variables and Arrays
  • Math... $((EXPRESSION))
  • Spacing
    • Critical
    • Maddening
12 / 13

Control

  • Functions
# Define
function_name() {
statements
}
# Invoke
function_name
# Delete
unset .f function_name
  • Loops
    • while (while, do, done)
    • for
    • until
    • select
    • break/continue
  • Conditionals
    • if (if, then, elif, then, else, fi)
13 / 13

Big News (1 of 3)

Marcus M. Darden, Jr.

  • New edition addition guy... Marcus, Jr.
  • Big & Fast
2 / 13
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow