Update shell_cheatsheet.md
[swc-modular-shell.git] / shell_cheatsheet.md
index ce0cba03ca5f39a8d1b443736bbdbba9e8ed95f5..56dad1fbf52f541618073367c589589626dd7e15 100644 (file)
@@ -59,14 +59,35 @@ text strings as arguments.
 
 See the cheatsheet on regular expressions for more "wildcard" shortcuts.
 
-### 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...
+### b) How to redirect to a file and get input from a file ...
+Redirection operators can be used to redirect the ouput from a program from the display screen to a file where it is saved (or many other places too, like your printer or to another program where it can be used as input).
 
 
+| Command | Description                                                                                                                     |  
+|---------|---------------------------------------------------------------------------------------------------------------------------------|  
+| `>`     | write `stdout` to a new file; overwrites any file with that name (e.g., `ls *.md > mardkownfiles.txt`)                          |  
+| `>>`    | append `stdout` to a previously existing file; if the file does not exist, it is created (e.g., `ls *.md >> markdownfiles.txt`) |  
+| `<`     | assigns the information in a file to a variable, loop, etc (e.g., `n < markdownfiles.md`)                                       | 
+
+
+
+#### b.1) How to use the output of one command as the input to another with a pipe...
+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) |  
+
+
+
+
+Example:   
+
+    ls *.md | head | sed -i `s/markdown/software/g`
+   
+changes all the instances of the word `markdown` to `software` in the first 5 `*.md` files in your current directory.
+
 
 ## 4. Variables
 ### a) Assignment