Update shell_cheatsheet.md
[swc-modular-shell-hearing.git] / shell_cheatsheet.md
index 2b1ebcce546e9877c261bfadb52e111fdcf4dcea..df2185534ff8ffa091b6d4f7d4ce64204107d9b9 100644 (file)
@@ -3,7 +3,7 @@
 
 ## 1. Shell Basics:
 
-| Symbol         | Definition                                                                                                     |
+| Command        | Definition                                                                                                     |
 |----------------|----------------------------------------------------------------------------------------------------------------|  
 | `.`            | a single period refers to the current directory                                                                |  
 | `..`           | a double period refers to the directory immediately above the current directory                                |  
 ## 2. Creating Things:
 ### a) How to create new files and directories..
 
-
-`mkdir ./dirname` | makes a new directory called dirname below the current directory. _Note:_ Windows users will need to use `\` instead of `/` for the path separator
-`nano filename`   | if `filename` does not exist, `nano` creates it and opens the `nano` text editor. If the file exists, `nano` opens it. _Note:_ _(i)_ You can use a different text editor if you like.  In gnome Linux, `gedit` works really well too. _(ii)_ `nano` (or `gedit`) create text files. It doesn't matter what the file extension is (or if there is one)
+| Command           | Definition                                                                                                                                                                                                                                                                                                                                            |  
+|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|  
+| `mkdir ./dirname` | makes a new directory called dirname below the current directory. _Note:_ Windows users will need to use `\` instead of `/` for the path separator                                                                                                                                                                                                    |  
+| `nano filename`   | if `filename` does not exist, `nano` creates it and opens the `nano` text editor. If the file exists, `nano` opens it. _Note:_ _(i)_ You can use a different text editor if you like.  In gnome Linux, `gedit` works really well too. _(ii)_ `nano` (or `gedit`) create text files. It doesn't matter what the file extension is (or if there is one) |  
 
 ### b) How to delete files and directories...
 #### _Remember that deleting is forever. There is NO going back_
-* **`rm ./filename`** --> deletes a file called `filename` from the current directory 
-* **`rmdir ./dirname`** --> deletes the directory `dirname` from the current directory. _Note:_ `dirname` must be empty for `rmdir` to run.
+
+| Command           | Definition                                                                                                       |  
+|-------------------|------------------------------------------------------------------------------------------------------------------|
+| `rm ./filename`   | deletes a file called `filename` from the current directory                                                      |  
+| `rmdir ./dirname` |  deletes the directory `dirname` from the current directory. _Note:_ `dirname` must be empty for `rmdir` to run. |  
 
 ### c) How to copy and rename files and directories...
-* **`mv tmp/filename .`** --> moves the file `filename` from the directory `tmp` to the current directory. _Note:_ _(i)_ the original `filename` in `tmp` is deleted. _(ii)_ `mv` can also be used to rename files (e.g., `mv filename newname`
-* **`cp tmp/filename .`** --> copies the file `filename` from the directory `tmp` to the current directory. _Note:_ _(i)_ the original file is still there
+
+| Command | Definition                                                                                                                                                                                                                    |  
+|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|  
+| `mv tmp/filename .` | moves the file `filename` from the directory `tmp` to the current directory. _Note:_ _(i)_ the original `filename` in `tmp` is deleted. _(ii)_ `mv` can also be used to rename files (e.g., `mv filename newname` |  
+| `cp tmp/filename .` | copies the file `filename` from the directory `tmp` to the current directory. _Note:_ _(i)_ the original file is still there                                                                                      |  
 
 
 
 ## 3. Pipes and Filters
 ### a) How to use wildcards to match filenames...
 Wildcards are a shell feature that makes the command line much more powerful than any GUI file managers. 
+Wildcards are particularly useful when you are looking for directories, files, or file content that can
+vary along a given dimension.  These wildcards can be used with any command that accepts file names or 
+text strings as arguments.
 
-
-** Table of commonly used wildcards **
+#### Table of commonly used wildcards 
 
 | Wildcard               | Matches                                        |  
 |------------------------|------------------------------------------------|  
@@ -48,11 +57,22 @@ Wildcards are a shell feature that makes the command line much more powerful tha
 | `[!a-e]`               | any character that is not in the given range   |  
 | `{software,carpentry}` | exactly one entire word from the options given |  
 
+See the cheatsheet on regular expressions for more "wildcard" shortcuts.
+
+### b) How to redirect to a file and get input from a file ...
+
+#### Definitions:
+*  **stdout**:
+*  **stdin**:
+*  **stderr**:
 
+| Command | Description |  
+|---------|-------------|
+| `>`     |
+| `>>`    |
+| `<`     |
+| `<<`    |
 
-### b) That wildcards are expanded by the shell before commands are run...
-### c) How to redirect a command's output to a file...
-### d) How to redirect a command's input from a file...
 ### e) How to use the output of one command as the input to another with a pipe...
 ### f) That combining single-purpose filters with pipes is the most productive way to use the shell...
 ### g) That if a program conforms to Unix conventions, it can easily be combined with others...