Renamed submodule path to gen/missing_semester_2020
This commit is contained in:
parent
74077578cb
commit
4346725ac2
10 changed files with 698 additions and 0 deletions
107
gen/missing_semester_2020/.gitignore
vendored
Normal file
107
gen/missing_semester_2020/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
# Created by https://www.toptal.com/developers/gitignore/api/vim,emacs,osx
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,emacs,osx
|
||||
|
||||
*.html
|
||||
*.css
|
||||
*.css.map
|
||||
|
||||
### Emacs ###
|
||||
# -*- mode: gitignore; -*-
|
||||
*~
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
auto-save-list
|
||||
tramp
|
||||
.\#*
|
||||
|
||||
# Org-mode
|
||||
.org-id-locations
|
||||
*_archive
|
||||
|
||||
# flymake-mode
|
||||
*_flymake.*
|
||||
|
||||
# eshell files
|
||||
/eshell/history
|
||||
/eshell/lastdir
|
||||
|
||||
# elpa packages
|
||||
/elpa/
|
||||
|
||||
# reftex files
|
||||
*.rel
|
||||
|
||||
# AUCTeX auto folder
|
||||
/auto/
|
||||
|
||||
# cask packages
|
||||
.cask/
|
||||
dist/
|
||||
|
||||
# Flycheck
|
||||
flycheck_*.el
|
||||
|
||||
# server auth directory
|
||||
/server/
|
||||
|
||||
# projectiles files
|
||||
.projectile
|
||||
|
||||
# directory configuration
|
||||
.dir-locals.el
|
||||
|
||||
# network security
|
||||
/network-security.data
|
||||
|
||||
|
||||
### OSX ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### Vim ###
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
!*.svg # comment out if you don't need vector files
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/vim,emacs,osx
|
||||
3
gen/missing_semester_2020/.gitmodules
vendored
Normal file
3
gen/missing_semester_2020/.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "_share/media/sass/org-media-sass"]
|
||||
path = _share/media/sass/org-media-sass
|
||||
url = git@bitbucket.org:ronnyabraham/org-media-sass.git
|
||||
1
gen/missing_semester_2020/_share/media/fonts
Symbolic link
1
gen/missing_semester_2020/_share/media/fonts
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/Users/ronny/notes/_share/media/fonts
|
||||
BIN
gen/missing_semester_2020/_share/media/img/lecture01/ex01.png
Normal file
BIN
gen/missing_semester_2020/_share/media/img/lecture01/ex01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
1
gen/missing_semester_2020/_share/media/js/collapsible.js
Symbolic link
1
gen/missing_semester_2020/_share/media/js/collapsible.js
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/Users/ronny/notes/_share/media/js/collapsible.js
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
@use "sass:map"
|
||||
@use "sass:color"
|
||||
|
||||
@use 'org-media-sass/default-org-mode'
|
||||
|
||||
@use 'org-media-sass/themes/desert-oasis' as *
|
||||
@use 'org-media-sass/fonts' as fonts
|
||||
@use 'org-media-sass/mixins' as mixins-basic
|
||||
|
||||
@include mixins-basic.set-header-sizes($default-header-sizes)
|
||||
@include mixins-basic.set-header-colors($default-header-colors)
|
||||
@include mixins-basic.set-header-margins-sides($default-header-margins-sides)
|
||||
@include mixins-basic.set-header-margins-vertical($default-header-margins-vertical)
|
||||
|
||||
|
||||
/* Base Styles */
|
||||
body
|
||||
font-family: $primary-font
|
||||
color: $text-color
|
||||
background-color: $background-color
|
||||
|
||||
/* Link Styles */
|
||||
a
|
||||
color: $anchor-color
|
||||
|
||||
&:hover
|
||||
color: $anchor-hover-color
|
||||
|
||||
// Lists
|
||||
ul, ol
|
||||
padding-left: $list-padding-left
|
||||
|
||||
// Blockquotes
|
||||
blockquote
|
||||
border-color: $secondary-color
|
||||
color: color.adjust($text-color, $lightness: 10%)
|
||||
font-family: $secondary-font
|
||||
|
||||
// Tables
|
||||
table
|
||||
color: $text-color
|
||||
|
||||
th, td
|
||||
border-color: $table-border-color
|
||||
|
||||
th
|
||||
background-color: $table-header-bg
|
||||
color: $text-color
|
||||
|
||||
tr:nth-child(even)
|
||||
background-color: color.adjust($background-color, $lightness: 5%)
|
||||
|
||||
/* Code Block Styles */
|
||||
pre, code
|
||||
background-color: $code-background-color
|
||||
color: $code-text-color
|
||||
|
||||
font-family: $secondary-font
|
||||
|
||||
/* Header Styles */
|
||||
h1, h2, h3, h4, h5, h6
|
||||
font-family: $secondary-font
|
||||
|
||||
h4[id="timestamp"]
|
||||
text-transform: uppercase
|
||||
color: color.adjust(map.get($default-header-colors, 'h3'), $lightness: 10%)
|
||||
|
||||
h4[id="playlist"]
|
||||
color: color.adjust(map.get($default-header-colors, 'h3'), $lightness: -10%)
|
||||
h3
|
||||
a
|
||||
color: color.adjust($anchor-color, $lightness: -12%)
|
||||
&:hover
|
||||
color: color.adjust($anchor-hover-color, $lightness: -12%)
|
||||
|
||||
// Notes
|
||||
.note
|
||||
background-color: $note-background-color
|
||||
border-color: $note-border-color
|
||||
color: $text-color
|
||||
|
||||
div#postamble
|
||||
border-color: $note-border-color
|
||||
color: color.adjust($note-border-color, $lightness: 20%)
|
||||
|
||||
/* Table of Contents Link */
|
||||
.toc
|
||||
color: $primary-color
|
||||
|
||||
div#table-of-contents ul li a
|
||||
color: $toc-anchor-color
|
||||
&:hover
|
||||
color: $toc-anchor-hover-color
|
||||
133
gen/missing_semester_2020/_subsections/lesson-01.org
Normal file
133
gen/missing_semester_2020/_subsections/lesson-01.org
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
#+title: Lesson 01 | Course Overview + Shell
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/missing-semester.css" />
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/org-media-sass/collapsible.css" />
|
||||
#+HTML_HEAD: <script src="../_share/media/js/collapsible.js"></script>
|
||||
|
||||
* Links
|
||||
#+attr_html: :class links
|
||||
- [[../toc.org][TOC | Missing Semester]]
|
||||
- [[https://www.youtube.com/playlist?list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J][Playlist: Missing Semester]]
|
||||
|
||||
*** timestamps
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: timestamp
|
||||
:END:
|
||||
|
||||
#+attr_html: :class playlist
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=20s][00:20 why we're doing this class]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=251s][04:11 the shell]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=338s][05:38 install a terminal and a shell]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=364s][06:05 the shell prompt]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=411s][06:51 shell prompt]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=522s][08:42 how does the shell know what these programs are]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=672s][11:12 paths]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=738s][12:18 absolute path]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=759s][12:39 relative paths]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1034s][17:14 tilde character]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1336s][22:16 directories]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1376s][22:56 execute on directories]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1514s][25:14 cp command]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1547s][25:47 rm]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1590s][26:30 create a new directory]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1912s][31:52 pipe character]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2044s][34:04 grep]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2145s][35:45 the root user]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2239s][37:19 kernel paramters]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2612s][43:32 scroll lock led]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2706s][45:06 open a file]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2829s][47:09 lecture notes]]
|
||||
- [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2875s][office hours]]
|
||||
|
||||
* Notes
|
||||
** why
|
||||
- there are many tools that make life easier for programmers
|
||||
- lecture notes and recordings are available online
|
||||
|
||||
** the shell
|
||||
- programs are meant to be integrates with each other through the shell
|
||||
- most common shell is Bourne Again Shell (bash)
|
||||
|
||||
** shell prompt
|
||||
- typical shell prompt:
|
||||
#+attr_html: :width 300px
|
||||
file:../_share/media/img/lecture01/ex01.png
|
||||
|
||||
- shells can be customized extensibly
|
||||
- arguments are seperated by whitespace
|
||||
- multiple words can be passed as a single argument via:
|
||||
- quotes
|
||||
#+begin_src bash
|
||||
echo "Hello world"
|
||||
#+end_src
|
||||
|
||||
- escapes
|
||||
#+begin_src bash
|
||||
echo Hello\ world
|
||||
#+end_src
|
||||
|
||||
** how does the shell know where programs are
|
||||
- via environment variable
|
||||
- things that are set whenever you start your shell
|
||||
- where is your home directory
|
||||
- what is your username
|
||||
- what are the PATHs to your programs
|
||||
- shells, and bash in particular, are programming languages
|
||||
|
||||
** paths
|
||||
*** PATH environment variable
|
||||
|
||||
- a list seperated by colons (:)
|
||||
- when bash is asked to run a program bash will search through the directories in path until it finds the program
|
||||
|
||||
*** absolute vs relative path
|
||||
|
||||
- pwd: print working directory
|
||||
- all relative paths are relative to your current working directory
|
||||
- absolute path starts with '/'
|
||||
|
||||
*** special directories
|
||||
- '.' current directory
|
||||
- '..' parent directory
|
||||
|
||||
*** tilde (~)
|
||||
- always expands to your home directory
|
||||
|
||||
*** dash (-)
|
||||
- toggles to the previous directory you were at
|
||||
|
||||
#+begin_src bash
|
||||
cd /home/ronny/programs/notes/courses
|
||||
cd ../../
|
||||
cd -
|
||||
pwd
|
||||
#+end_src
|
||||
|
||||
the output will be
|
||||
=/home/ronny/programs/notes/courses=
|
||||
|
||||
** permissions
|
||||
*** groups of three
|
||||
- read
|
||||
- write
|
||||
- execute
|
||||
|
||||
*** directories
|
||||
- read: are you allowed to see the files
|
||||
- write: can you rename the files in the directory
|
||||
- execute: "search" are you allowed to enter this directory
|
||||
- to access a file in a directory, you need execute permissions on all directories in the path
|
||||
|
||||
** piping
|
||||
- every program has two streams
|
||||
- input stream
|
||||
- output stream
|
||||
- shell allows you to change streams
|
||||
- angle brackets
|
||||
- left angle < : rewire input
|
||||
- right angle > : rewire output
|
||||
|
||||
- example
|
||||
#+begin_src bash
|
||||
echo hello > hello.txt
|
||||
cat < hello.txt
|
||||
#+end_src
|
||||
288
gen/missing_semester_2020/_subsections/lesson-02.org
Normal file
288
gen/missing_semester_2020/_subsections/lesson-02.org
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
#+title: lesson 02 | course overview + the shell
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/missing-semester.css" />
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/org-media-sass/collapsible.css" />
|
||||
#+HTML_HEAD: <script src="../_share/media/js/collapsible.js"></script>
|
||||
|
||||
* Links
|
||||
#+attr_html: :class links
|
||||
- [[../toc.org][TOC | Missing Semester]]
|
||||
- [[https://www.youtube.com/playlist?list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J][Playlist: Missing Semester]]
|
||||
|
||||
- Curr: https://youtu.be/kgII-YWo3Zw?si=Wm8KLT1ggOGG8W-g&t=1692
|
||||
|
||||
|
||||
*** timestamps
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: timestamp
|
||||
:END:
|
||||
|
||||
#+attr_html: :class playlist
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=54s][00:54 - control flow functions]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=227s][03:47 - sequential execution]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=425s][07:05 - standard input]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=444s][07:24 - error code]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=517s][08:37 - logical operators]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=603s][10:03 - concatenate commands]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=645s][10:45 - common substitution]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=675s][11:15 - process substitution]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=935s][15:35 - comparison operator]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1173s][19:33 - curly braces]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1359s][22:39 - python script]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1707s][28:27 - man command]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2175s][31:26 - finding files]] *current*
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2190s][36:30 - grep]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2573s][42:53 - fuzzy finder]]
|
||||
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2649s][44:09 - history substring search]]
|
||||
|
||||
* Notes
|
||||
|
||||
** bash
|
||||
*** spaces are critical with bash
|
||||
- this works:
|
||||
#+begin_src bash
|
||||
foo=bar
|
||||
echo $foo
|
||||
#+end_src
|
||||
|
||||
- this doesn't:
|
||||
#+begin_src bash
|
||||
foo = bar
|
||||
echo $foo
|
||||
#+end_src
|
||||
|
||||
- the output of that will be
|
||||
=zsh: command not found: foo=
|
||||
|
||||
- what happens in the above example is that we are effectively calling the "foo" program with the arguments: "=" and "bar"
|
||||
|
||||
*** quotes
|
||||
- you can use double or single quotes to print a value
|
||||
#+begin_src bash
|
||||
echo "Hello"
|
||||
#+end_src
|
||||
#+begin_src bash
|
||||
echo 'Hello'
|
||||
#+end_src
|
||||
|
||||
- double quotes can interpolate variables
|
||||
#+begin_src bash
|
||||
echo "Value is $foo"
|
||||
#+end_src
|
||||
|
||||
will return: =Value is bar=
|
||||
|
||||
- single quotes can NOT interpoloate variables
|
||||
#+begin_src bash
|
||||
echo 'Value is $foo'
|
||||
#+end_src
|
||||
|
||||
will return: =Value is $foo=
|
||||
|
||||
** sequential execution
|
||||
|
||||
*** bash functions
|
||||
- mcd.sh
|
||||
#+begin_src bash
|
||||
mcd() {
|
||||
mkdir -p "$1"
|
||||
cd "$1"
|
||||
}
|
||||
#+end_src bash
|
||||
|
||||
- creates a function that can be executed after loading
|
||||
- $1 is a global variable referring to the first parameter
|
||||
|
||||
*** source
|
||||
- using source mcd.sh
|
||||
=source mcd.sh=
|
||||
|
||||
- then carry out the function
|
||||
=mcd testdir=
|
||||
|
||||
- this will create a new directory and cd into it as per the definied functioned
|
||||
|
||||
** error codes
|
||||
*** commands to access codes or values
|
||||
- $0 -- name of the script we are currently in
|
||||
- if you run this in the shell it will display 'bash'
|
||||
- $1->$9 -- the first through ninth argument given to a script
|
||||
- $? -- the last error message
|
||||
- $_ --- last argument of the previous call
|
||||
|
||||
- !! -- recreates the last call with it's arguments
|
||||
- use with sudo if you found your call needed a sudo and you don't feel like retyping it again
|
||||
|
||||
#+begin_src bash
|
||||
ls -lah
|
||||
sudo !!
|
||||
#+end_src
|
||||
|
||||
*** code values
|
||||
- boolean
|
||||
- true returns an error code of 0
|
||||
- false returns an error code of 1
|
||||
|
||||
** using $@ and $*
|
||||
- represents all the arguments passed to a script or a function as separate, individual strings. It preserves each argument as a distinct item, even if the argument contains spaces.
|
||||
|
||||
*** key points about $@
|
||||
1. All Arguments: It refers to all the command-line arguments passed to the script.
|
||||
2. Preserves Spaces: If an argument contains spaces, it is treated as a single argument.
|
||||
3. Usage: It is commonly used in a loop to iterate over each argument.
|
||||
|
||||
*** example
|
||||
#+begin_src bash
|
||||
./myscript.sh file1.txt "file with spaces.txt" file3.txt
|
||||
#+end_src
|
||||
|
||||
then $@ will be
|
||||
=file1.txt "file with spaces.txt" file3.txt=
|
||||
|
||||
*** differences between $*
|
||||
- *$@* treats each argument as a sepearte item
|
||||
- *$** treats all arguments as a single, combined string
|
||||
|
||||
|
||||
** logical operators
|
||||
- you can use the error return value in conditionals
|
||||
*** example using the OR conditional
|
||||
#+begin_src bash
|
||||
false || echo "Oops fail"
|
||||
"Oops fail"
|
||||
#+end_src
|
||||
|
||||
*** example using the AND conditional
|
||||
#+begin_src bash
|
||||
true && echo "this will print"
|
||||
"this will print"
|
||||
#+end_src
|
||||
|
||||
** concatenate commands
|
||||
- you caoncatinate commands using the semicolon: *;*
|
||||
|
||||
#+begin_src bash
|
||||
false; echo "this prints always"
|
||||
"this prints always"
|
||||
#+end_src
|
||||
|
||||
** common substitution
|
||||
- take the output of a command and put it in a variable
|
||||
#+begin_src bash
|
||||
foo=$(pwd)
|
||||
echo $foo
|
||||
"/Users/ronny/..."
|
||||
#+end_src
|
||||
|
||||
- this can also be done by placing that format in a string and it will expand the string
|
||||
#+begin_src bash
|
||||
echo "the pwd output is: $(pwd)"
|
||||
"the pwd output is: /Users/ronny/..."
|
||||
#+end_src
|
||||
|
||||
** process substitution
|
||||
*** description
|
||||
Bash process substitution is a feature that allows you to use the output of a command or a process as if it were a file. It enables you to redirect input or output between processes in a flexible way without needing intermediate temporary files.
|
||||
|
||||
*** Syntax
|
||||
- creates a temporary file descriptor for the output of the command, which can be used as an input file in another command.
|
||||
#+begin_src bash
|
||||
<(command)
|
||||
#+end_src
|
||||
- creates a temporary file descriptor for writing to the command, which can be used as an output file in another command.
|
||||
#+begin_src bash
|
||||
>(command)
|
||||
#+end_src
|
||||
|
||||
*** examples
|
||||
- this will take b, a, d, c and sort it so the result is 'a, b, c, d'
|
||||
#+begin_src bash
|
||||
sort <(echo -e "b\na") <(echo -e "d\nc")
|
||||
#+end_src
|
||||
|
||||
- this will list the files, send the list to *tee* which will split a portion off to the screen and the rest to grep, followed by text_files.txt
|
||||
|
||||
#+begin_src bash
|
||||
ls | tee >(grep "txt" > text_files.txt)
|
||||
#+end_src
|
||||
|
||||
#+begin_src bash
|
||||
echo "Starting program at $(date)" # Date will be substituted
|
||||
echo "Running program $0 with $# arguments with pid $$"
|
||||
|
||||
for file in "$@"; do
|
||||
grep foobar "$file" > /dev/null 2> /dev/null
|
||||
|
||||
# when pattern is not found, grep has exit status 1
|
||||
# we redirect STDOUT and STDERR to a null register since we do not care about them
|
||||
|
||||
if [[ "$?" - ne 0 ]]; then
|
||||
echo "File $file does not have any foober adding one"
|
||||
echo "# foobar" >> "$file"
|
||||
fi
|
||||
done
|
||||
#+end_src
|
||||
|
||||
- *$$* pid given for program
|
||||
- *$#* number of arguments
|
||||
- *$@* expands to all the arguments
|
||||
- can be used in a for loop
|
||||
- *2>* refers to STDERR
|
||||
- *>* refers to STDOUT
|
||||
|
||||
** test utility
|
||||
|
||||
test is a bash utility that you can use to test the condition of a file. look at the man page for more info
|
||||
|
||||
** curly braces
|
||||
curly braces are used as a form of program command expansion.
|
||||
|
||||
the braces contain a number of arguments seperated by commans that will expand into arguments for the program
|
||||
|
||||
*** example
|
||||
#+begin_src bash
|
||||
touch foo{,1,2,10}
|
||||
touch foo foo1 foo2 foo10
|
||||
|
||||
cp foo{,.old}
|
||||
cp foo foo.old
|
||||
#+end_src
|
||||
|
||||
*** ranges
|
||||
this takes the format {1..20}
|
||||
|
||||
#+begin_src bash
|
||||
touch directory{1..4}/foo{a..z}.txt
|
||||
#+end_src
|
||||
|
||||
** python scripts
|
||||
*** making them bash executable
|
||||
- reference the python compiler at the top of the file
|
||||
- do it directly:
|
||||
#+begin_src bash
|
||||
#!/usr/local/bin/python
|
||||
#+end_src
|
||||
- use the env program to do so
|
||||
#+begin_src bash
|
||||
#!/usr/bin/env python
|
||||
#+end_src
|
||||
|
||||
*** args can be found through sys.argv[1:]
|
||||
#+begin_src python
|
||||
import sys
|
||||
for arg in reversed(sys.argv[1:]):
|
||||
print(arg)
|
||||
#+end_src
|
||||
|
||||
** checking for problems in bash scripts using 'shellcheck'
|
||||
#+begin_src bash
|
||||
shellcheck some_bash_script.sh
|
||||
#+end_src
|
||||
|
||||
- will tell you problems
|
||||
- and warnings
|
||||
|
||||
** man command
|
||||
- works with both os, and installed tools
|
||||
- 'tldr' is easier to read
|
||||
|
||||
** find
|
||||
38
gen/missing_semester_2020/_subsections/lesson-03.org
Normal file
38
gen/missing_semester_2020/_subsections/lesson-03.org
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#+title: Lesson 02 | shell tools and scripting
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/missing-semester.css" />
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/org-media-sass/collapsible.css" />
|
||||
#+HTML_HEAD: <script src="../_share/media/js/collapsible.js"></script>
|
||||
|
||||
* Links
|
||||
#+attr_html: :class links
|
||||
- [[../toc.org][TOC | Missing Semester]]
|
||||
- [[https://www.youtube.com/playlist?list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J][Playlist: Missing Semester]]
|
||||
|
||||
* Notes
|
||||
|
||||
|
||||
*** Playlist
|
||||
|
||||
#+attr_html: :class playlist
|
||||
1. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=20s][why we're doing this class]]
|
||||
2. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=251s][the shell]]
|
||||
3. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=338s][install a terminal and a shell]]
|
||||
4. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=411s][shell prompt]]
|
||||
5. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=522s][how does the shell know what these programs are]]
|
||||
6. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=672s][paths]]
|
||||
7. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=738s][absolute path]]
|
||||
8. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=759s][relative paths]]
|
||||
9. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1034s][tilde character]]
|
||||
10. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1336s][directories]]
|
||||
11. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1376s][execute on directories]]
|
||||
12. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1514s][cp command]]
|
||||
13. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1547s][rm]]
|
||||
14. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1590s][create a new directory]]
|
||||
15. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1912s][pipe character]]
|
||||
16. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2044s][grep]]
|
||||
17. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2145s][the root user]]
|
||||
18. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2239s][kernel paramters]]
|
||||
19. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2612s][scroll lock led]]
|
||||
20. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2706s][open a file]]
|
||||
21. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2829s][lecture notes]]
|
||||
22. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2875s][office hours]]
|
||||
34
gen/missing_semester_2020/toc.org
Normal file
34
gen/missing_semester_2020/toc.org
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#+title: Missing Semester IAP 2020
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="_share/media/css/missing-semester.css" />
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="_share/media/css/org-media-sass/content-overview.css" />
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="_share/media/css/org-media-sass/collapsible.css" />
|
||||
#+HTML_HEAD: <script src="_share/media/js/collapsible.js"></script>
|
||||
|
||||
* Links
|
||||
#+attr_html: :class links
|
||||
- [[../../../course-listings.org][Courses Listing]]
|
||||
- [[https://www.youtube.com/playlist?list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J][YouTube Playlist: Missing Semester]]
|
||||
|
||||
*** playlist
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: playlist
|
||||
:END:
|
||||
|
||||
#+attr_html: :class playlist
|
||||
1. [[https://youtu.be/Z56Jmr9Z34Q?si=XHgfjMWOSx0lSUV8][Lecture 1: Course Overview + The Shell]]
|
||||
2. [[https://youtu.be/kgII-YWo3Zw?si=yOa5im_cHzisLeZn][Lecture 2: Shell Tools and Scripting]]
|
||||
3. [[https://youtu.be/a6Q8Na575qc?si=7cgWLJfBgtzVvUUC][Lecture 3: Editors]]
|
||||
4. [[https://youtu.be/sz_dsktIjt4?si=l9M6_yIDqV1drxNS][Lecture 4: Data Wrangling]]
|
||||
5. [[https://youtu.be/e8BO_dYxk5c?si=a6aWoJSVS13rQO1I][Lecture 5: Command-line Environment]]
|
||||
6. [[https://youtu.be/2sjqTHE0zok?si=ArLpMvXhrtAsQnLH][Lecture 6: Version Control (git)]]
|
||||
7. [[https://youtu.be/l812pUnKxME?si=BDElINPHWLHQzBcD][Lecture 7: Debugging and Profiling]]
|
||||
8. [[https://youtu.be/_Ms1Z4xfqv4?si=tMk44R213bG70pCq][Lecture 8: Metaprogramming]]
|
||||
9. [[https://youtu.be/tjwobAmnKTo?si=QnIhfVK8mJHCV6PU][Lecture 9: Security and Cryptography]]
|
||||
10. [[https://youtu.be/JZDt-PRq0uo?si=7oCytjjvVaGSTDHr][Lecture 10: Potpourri]]
|
||||
11. [[https://youtu.be/Wz50FvGG6xU?si=Gmp-YJZm0sR65GAa][Lecture 11: Q&A]]
|
||||
|
||||
* Contents Overview
|
||||
#+attr_html: :class contents-overview
|
||||
- [[./_subsections/lesson-01.org][Lesson 01 | Course Overview + The Shell]]
|
||||
- [[./_subsections/lesson-02.org][Lesson 02 | Shell Tools and Scripting]]
|
||||
|
||||
Loading…
Add table
Reference in a new issue