Skip to content

Commit 0ad3751

Browse files
Update README.md
1 parent 2f5be8d commit 0ad3751

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

README.md

+4-17
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,12 @@ For example, the following will send the `ls` output to `head` so that only the
221221
$ ls -l | head
222222
```
223223
##Input/Output Redirection
224-
I/O redirection is a handy tool that allows the user to send the output of a command somewhere other then the screen or even have a command accept input from somewhere other than the keyboard.
224+
I/O redirection allows the user to send the output of a command somewhere other then the screen or even have a command accept input from somewhere other than the keyboard.
225225
###Output Redirection
226226
Standard output redirection uses the symbols `>` and `>>`. <br>
227-
Most commands such as `ls` send their results to standard output, which prints to the screen.
228-
Instead of printing to the screen we can redirect the standard output to print into a file.
229-
The command goes before the symbol and the file goes after the symbol, as follows:
227+
For example, the following will send the output of `ls` into the file instead of printing to the screen.
230228
```
231229
ls > files.txt
232-
```
233-
If we ran `ls` on its own we may get a results such as:
234-
```
235-
$ ls
236-
file1.cpp sample.txt
237-
```
238-
But if we run the above command with output redirection, there will be no output to the display, the output will be in a file, such as:
239-
```
240-
$ ls > files.txt
241230
$ cat files.txt
242231
file1.cpp sample.txt
243232
```
@@ -247,8 +236,7 @@ If the file already exists, then the contents of the command will overwrite what
247236
To avoid overwriting a file, the `>>>` command will do the same thing as the `>` command except it will append to the end of the file instead.
248237
###Input Redirection
249238
Standard input redirection uses the symbol `<`. <br>
250-
Just like standard output redirection, the command goes before the symbol and the file that the command will be getting its input from goes after the symbol.
251-
Running the command `sort` with `<` will cause sort to access the input necessary to execute from the input file instead of standard input, such as:
239+
For example, the following will cause `sort` to access its input from the file instead of the keyboard.
252240
```
253241
$ cat files.txt
254242
a
@@ -264,8 +252,7 @@ But we can combine I/O redirection into one command line, such as:
264252
```
265253
$ sort < files.txt > files_sorted.txt
266254
```
267-
Notice that nothing got printed to the screen.
268-
That is because the output was now sent to the files_sorted.txt file.
255+
The output is now being sent to the files_sorted.txt file.
269256
###Advanced Redirection
270257
Adding a `&` with the `>` symbol will result in redirecting both standard out and standard error.
271258
For example, running the following command on a file named "test.cpp" that prints the string "stdout" with `cout` and the string "stderr" with `cerr` will result in the following output:

0 commit comments

Comments
 (0)