Update shell_cheatsheet.md
[swc-modular-shell-hearing.git] / shell_cheatsheet.md
index 7cc29caf48fe96faeca911cb84c2b6f9c145dbf8..14bcdd3026dac8644d4da43be6412215dce2b39c 100644 (file)
@@ -77,7 +77,8 @@ A special kind of redirection is called a pipe and is denoted by `|`.
 
 | Command | Description                                                                                                                                           |  
 |---------|-------------------------------------------------------------------------------------------------------------------------------------------------------|  
-| `|`     | Output from one command line program can be used as input to another one (e.g. `ls *.md | head` gives you the first 5 `*.md` files in your directory) |  
+| |     | Output from one command line program can be used as input to another one (e.g. ls \*.md | head gives you the first 5 `*.md` files in your directory) |  
+
 
 
 
@@ -165,26 +166,36 @@ continues the loop as long as the value in the variable COUNTER is less than 10
 
 ## 6. Finding Things
 ### a) How to select lines matching patterns in text files...
+To find information within files, you use a command called `grep`.
+
+| Example command                | Description                                                                                    |
+|--------------------------------|------------------------------------------------------------------------------------------------|
+| `grep [options] day haiku.txt` | finds every instance of the string `day` in the file haiku.txt and pipes it to standard output |                                                                                                                                                                                                                |  
 
-| Example command | Description |
-|-----------------|-------------|
-| `grep [options] day haiku.txt` | finds every instance of the string `day` in the file haiku.txt and pipes it to standard output |  
+#### a.1) Commonly used `grep` options
 
-| grep options |                                                                                                                                                                                                              |  
-|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|  
+|      | `grep` options                                                                                                                                                                                                       |  
+|------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|  
 | `-E` | tells grep you will be using a regular expression. Enclose the regular expression in quotes. _Note:_ the power of `grep` comes from using regular expressions. Please see the regular expressions sheet for examples |  
-| `-i` | makes matching case-insensitive |  
-| `-n` | limits the number of lines that match to the first n matches |  
-| `-v` | shows lines that do not match the pattern (inverts the match) |  
-| `-w` | outputs instances where the pattern is a whole word |  
+| `-i` | makes matching case-insensitive                                                                                                                                                                                      |  
+| `-n` | limits the number of lines that match to the first n matches                                                                                                                                                         |   
+| `-v` | shows lines that do not match the pattern (inverts the match)                                                                                                                                                        |  
+| `-w` | outputs instances where the pattern is a whole word                                                                                                                                                                  |  
 
 ### b) How to find files with certain properties...
-* **`find . -type d` -->
-       * **`-type [df]`** --> d lists directories; f lists files
-       * **`-maxdepth n`** --> `find` automatically searches subdirectories. If you don't want that, specify the number of levels below the working directory you would like to search
-       * **`-mindepth n`** --> starts `find`'s search n levels below the working directory
-       
-### c) How to use one command's output as arguments to another command...
-
-### d) How are text and binary files different?...
+To find file and directory names, you use a command called `find`
+
+| Example command  | Description |  
+|------------------|-------------|
+| `find . -type d` | `find` recursively descends the directory tree for each path listed to match the expression given in the command line with file or directory names in the search path |  
+
+
+#### b.1) Commonly used `find` options
+
+|               | `find` options                                                                                                                                          |  
+|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|  
+| `-type [df]`  | `d` lists directories; `f` lists files                                                                                                                  |  
+| `-maxdepth n` | `find` automatically searches subdirectories. If you don't want that, specify the number of levels below the working directory you would like to search |
+| `-mindepth n` | starts `find`'s search `n` levels below the working directory                                                                                           |
+