Definitions
1
# $PATH
2
​
3
# Add to beginning of $PATH
4
PATH=~/opt/bin:$PATH
5
​
6
# Add to end of $PATH
7
PATH=$PATH:~/opt/bin
Copied!
1
# Standard input & output
2
​
3
# Send output of command to a file instead of terminal
4
# Shell will create a file if it does not exist, if it does, the shell erases (clobbers) the original file first
5
command > file
6
​
7
# Append to file
8
command >> file
9
​
10
# Match every line that I type after that has 'this' in it and put the results in to hello_grep.txt file
11
grep this > hello_grep.txt
12
​
13
# Put all the lines matching 'line' into grep_output.txt file
14
grep line hello.txt > grep_output.txt
15
​
16
# >> Redirect output to append to FILE
17
grep line hello.txt >> grep_output.txt
18
​
19
# Redirect standard error stream to FILE
20
# where 2> means redirect output stream 2 to write results to the
21
# file and not to the terminal
22
find / -name 'story.txt' 2> error_log.txt
23
​
24
# 1> specifies stream ID 1 (standard output) (default)
25
# 2> specifies stream ID 2 (standard error)
26
​
27
# Sends both standard error and output to some location
28
ls /fffff > f 2>&1
Copied!
1
- Accept - Specifies the file format the requester wants.
2
- Accept-Language - Specifies the human-readable language, like English, Spanish, or Russian.
3
- Cache-Control - Specifies whether the response can be generated from a cache.
Copied!
1
# Globbing
2
​
3
# Shell can match simple patterns to file and directory names
4
# this process is known as globbing
5
​
6
# Simplest of these is the glob character * which tells the shell to match any number of arbitrary characters
7
​
8
# Print a list of files in current directory
9
echo *
10
​
11
# Shell matches arguments containing globs to filenames
12
# substititutes the filenames for those arguments, and then runs the revised command line
13
# the substitution is called expansion because the shell substitutes all matching filenames
14
​
15
​
16
at* # Expands to all filenames that start with at
17
​
18
*at # Expands to all filenames that end with at
19
​
20
*at* # Expands to all filenames that contain at
21
​
22
​
23
# Another shell glob character is (?) - it instructs the shell to match exactly one arbitrary character
24
​
25
# Match both boat and brat
26
b?at
27
​
28
# If you don't want the shell to expand a glob in a command, enclose the glob in single quotes ('')
29
​
30
# It is important to remember that the shell performs expansions before running commands
Copied!
1
ASCII code
2
​
3
- ASCII is an encoding representing each typed letter by a number
4
- each number is stored in one byte (so the number is in 0..255)
5
- A is 65
6
- B is 66
7
- space is 32
8
- "Unicode" is an encoding for mandarin, greek, arabic, etc. languages
9
- typically 2-bytes per "letter"
10
​
11
![](https://i.imgur.com/qbFb4Ik.png)
Copied!
1
HTTP status codes
2
​
3
- 200-299 are good
4
- 300-399 understood (located elsewhere)
5
- 400-499 error (404 = resource no longer exists)
6
- 400-599 server end (500 = some error on the server)
Copied!
1
HTTP REST methods
2
​
3
- GET - Used for fetching either a collection of resources or a single resource.
4
- POST - Used to add a new resource to a collection.
5
- For example, we wouldn't POST to /players/567 or /games/1234 because they aren't collections.
6
- We would, however, POST to /players or /games to create a new player or a new game.
7
- PUT - Use when we want to update a record. We wouldn't use PUT on collection or list URLs.
8
- DELETE - Used for sending a DELETE request to a detail record, a URL for a single record, should delete just that record.
9
- Sending DELETE to an entire collection would delete the whole collection but that's usually not implemented, with good reason.
Copied!
Last modified 1yr ago
Copy link