Skip to content

Commit caae98a

Browse files
committed
splitting lesson02 and lesson03
1 parent a0e35fb commit caae98a

File tree

2 files changed

+98
-89
lines changed

2 files changed

+98
-89
lines changed

lessons/lesson02.md

Lines changed: 35 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,55 @@
1-
## Lesson 02 - Command Line and Bash
1+
## Lesson 02 - Command Line Part I
22

33
Skills you will learn in this lesson:
44

5-
* Moving between directories and creating/removing files
6-
* Working with commands and processes
5+
* Moving between directories
6+
* Absolute and relative paths
7+
* Creating, moving, and removing files and directories
78
* Investigating text files
8-
* Parsing files
9-
* Working with input and output
10-
* Absolute and relative paths, symbolic links
11-
* Bash variables and commands
12-
* Text editors: nano, vim, emacs, Atom, Sublime Text, MacDown
13-
* Executing bash scripts and dot-files (e.g., `.bash_profile`)
14-
* Setting up your Terminal settings and bash environment
9+
* Working with commands and processes
10+
* GUI and command-line text editors
11+
* Setting up your bash environment
1512

1613
### Basic commands
1714

18-
#### Moving between directories and creating/removing files
15+
#### Moving between directories
1916

2017
* `pwd` -- print working directory
2118
* `ls` -- list contents of working directory
2219
* `cd DIRECTORY` -- change to directory
2320
* `cd` -- change to home directory
2421
* `cd -` -- change to previous directory
22+
23+
#### Absolute and relative paths
24+
25+
* `.` -- current directory
26+
* `..` -- one directory up
27+
* `../..` -- two directories up
28+
* `/` -- root directory
29+
* `~` -- home directory
30+
31+
#### Creating, moving, and removing files and directories
32+
2533
* `mkdir DIRECTORY` -- make directory
2634
* `rmdir DIRECTORY` -- remove empty directory
27-
* `touch FILE` -- create an empty file
35+
* `touch FILE` -- create an empty file or change file modification time
2836
* `cat FILE` -- print contents of file
2937
* `cat > FILE` -- write to file
3038
* `cat >> FILE` -- append to file
3139
* `cp FILE1 FILE2` -- copy file
3240
* `mv FILE1 FILE2` -- move file
3341
* `rm FILE` -- remove file
34-
* `exit` -- close the current session
42+
* `ln -s FILE LINK` -- make a symbolic link
43+
44+
#### Investigating text files
45+
46+
* `less FILE` -- view a text file
47+
* `head FILE` -- first 10 lines of file
48+
* `tail FILE` -- last 10 lines of file
49+
* `wc FILE` -- count the words and characters in a file
50+
* `open FILE` -- open a file using default program (on a Mac)
51+
* `file FILE` -- get the file type for file(s)
52+
* `grep REGEX FILE` -- search a text file for a string or regular expression
3553

3654
#### Working with commands and processes
3755

@@ -40,6 +58,7 @@ Skills you will learn in this lesson:
4058
* `which COMMAND` -- show location of command
4159
* `history` -- display past commands
4260
* `top` -- display current processes
61+
* `exit` -- close the current session
4362

4463
### Text editors
4564

@@ -53,9 +72,9 @@ A great way to document your work is using Markdown, a simple markup style. It i
5372

5473
For small jobs or if you want to stay inside the terminal, there are other useful programs. Note: `cat` is only useful for creating very basic files, or starting files and finishing them in a proper text editor.
5574

56-
* `nano FILE` - nano is the most basic text editor (see Appendix: The Nano Text Editor at end of this lesson)
57-
* `emacs FILE` - emacs is a popular full-featured text editor controlled by keystrokes
58-
* `vim FILE` - vim or vi is a popular competitor to emacs that loads faster
75+
* `nano FILE` -- nano is the most basic text editor (see Appendix: The Nano Text Editor at end of this lesson)
76+
* `emacs FILE` -- emacs is a popular full-featured text editor controlled by keystrokes
77+
* `vim FILE` -- vim or vi is a popular competitor to emacs that loads faster
5978

6079
### Setting up your bash environment
6180

@@ -92,79 +111,6 @@ alias rm='rm -i'
92111
alias taill='ls -lrt | tail'
93112
```
94113

95-
### More commands
96-
97-
#### Investigating text files
98-
99-
* `less FILE` -- view a text file
100-
* `head FILE` -- first 10 lines of file
101-
* `tail FILE` -- last 10 lines of file
102-
* `wc FILE` -- count the words and characters in a file
103-
* `open FILE` -- open a file using default program (on a Mac)
104-
* `file FILE` -- get the file type for file(s)
105-
* `grep REGEX FILE` -- search a text file for a string or regular expression
106-
107-
#### Parsing files
108-
109-
* `cut -d "," -f 5- FILE` -- output 5th field through end using comma field delimiter
110-
* `sed 's/FIND/REPLACE/g'` -- replace text in a file
111-
* `perl --e 's/FIND/REPLACE/g'` -- run perl commands in the command line (advanced)
112-
113-
#### Working with input and output
114-
115-
* `|` -- pipe output from one command to another
116-
* `>` -- redirect (write) to file
117-
* `<` -- get output of file (other type of redirect)
118-
* `` `COMMAND` `` -- pass output of a command (e.g., in a for loop)
119-
120-
#### Absolute and relative paths, symbolic links
121-
122-
* `.` -- current directory
123-
* `..` -- one directory up
124-
* `../..` -- two directories up
125-
* `/` -- root directory
126-
* `~` -- home directory
127-
* `ln -s FILE LINK` -- make a symbolic link
128-
129-
#### Wildcards
130-
131-
* `?` - match any single character
132-
* `*` - match any string of characters
133-
* `[set]` - match any character in set
134-
* `[!set]` - match any character *not* in set
135-
136-
#### Brace expansion
137-
138-
* `{start..end}` - expand a range; e.g., `b{ed,olt,ar}s`, `{2..5}`, `{d..h}`
139-
140-
#### Control keys
141-
142-
* `CTRL-C` - stop current command
143-
* `CTRL-D` - end of input
144-
* `CTRL-Z` - suspend current command
145-
146-
### Variables, bash scripts, and dot-files
147-
148-
#### Bash variables and commands
149-
150-
* `A=0` -- assign a variable
151-
* `echo VARIABLE` -- output the value of a variable or expression
152-
* `$PATH` -- your path variable
153-
* `$SHELL` -- your current shell
154-
* `$RANDOM` -- a random number
155-
* `$PPID` -- process ID
156-
* `$HOME` -- your home directory (another name for `~` or `/Users/you`)
157-
* `for VARIABLE in LIST; do COMMANDS; done` -- `for` loop in bash
158-
159-
#### Commands
160-
161-
* `bash SCRIPT.sh` -- run a bash shell script
162-
* `source .DOTFILE` -- run a dot-file like your .bash_profile
163-
164-
#### Bash scripts
165-
166-
Any of the commands we have used from the command line (the bash prompt `$`) can also be typed into a text file and executed by typing `bash SCRIPT.sh` from the command line.
167-
168114
### Appendix: The Nano Text Editor
169115

170116
Credit: [SDSU Department of Astronomy](http://mintaka.sdsu.edu/reu/nano.html)

lessons/lesson03.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## Lesson 03 - Command Line Part II
2+
3+
Skills you will learn in this lesson:
4+
5+
* Parsing files
6+
* Working with input and output
7+
* Wildcards
8+
* Brace expansion
9+
* Control keys
10+
* Bash variables and commands
11+
* Executing bash scripts and dot-files
12+
13+
### More commands
14+
15+
#### Parsing files
16+
17+
* `cut -d "," -f 5- FILE` -- output 5th field through end using comma field delimiter
18+
* `sed 's/FIND/REPLACE/g'` -- replace text in a file
19+
* `perl --e 's/FIND/REPLACE/g'` -- run perl commands in the command line (advanced)
20+
21+
#### Working with input and output
22+
23+
* `|` -- pipe output from one command to another
24+
* `>` -- redirect (write) to file
25+
* `<` -- get output of file (other type of redirect)
26+
* `` `COMMAND` `` -- pass output of a command (e.g., in a for loop)
27+
28+
#### Wildcards
29+
30+
* `?` -- match any single character
31+
* `*` -- match any string of characters
32+
* `[set]` -- match any character in set
33+
* `[!set]` -- match any character *not* in set
34+
35+
#### Brace expansion
36+
37+
* `{start..end}` -- expand a range; e.g., `b{ed,olt,ar}s`, `{2..5}`, `{d..h}`
38+
39+
#### Control keys
40+
41+
* `CTRL-C` -- stop current command
42+
* `CTRL-D` -- end of input
43+
* `CTRL-Z` -- suspend current command
44+
45+
### Variables, bash scripts, and dot-files
46+
47+
#### Bash variables and commands
48+
49+
* `A=0` -- assign a variable
50+
* `echo VARIABLE` -- output the value of a variable or expression
51+
* `$PATH` -- your path variable
52+
* `$SHELL` -- your current shell
53+
* `$RANDOM` -- a random number
54+
* `$PPID` -- process ID
55+
* `$HOME` -- your home directory (another name for `~` or `/Users/you`)
56+
* `for VARIABLE in LIST; do COMMANDS; done` -- `for` loop in bash
57+
58+
#### Executing bash scripts and dot-files
59+
60+
* `bash SCRIPT.sh` -- run a bash shell script
61+
* `source .DOTFILE` -- run a dot-file like your .bash_profile
62+
63+
Any of the commands we have used from the command line (the bash prompt `$`) can also be typed into a text file and executed by typing `bash SCRIPT.sh` from the command line.

0 commit comments

Comments
 (0)