-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
## Redirection | ||
|
||
> Redirect output to stdin of another command using `>` and to redirect standard input, we use `<`. | ||
```shell | ||
cat file.txt > file2.txt | ||
cat < file.txt | ||
# redirect stderr | ||
find / 2> /dev/null | ||
# redirect stdout and stderr | ||
find / 2> /dev/null 2>&1 | ||
``` | ||
|
||
> To redirect output of one command to input of another, we use piping `|`. | ||
```shell | ||
ls / | grep root | ||
``` | ||
* We cannot do this using `>` because, it writes to a file descriptor and `grep` takes in a file descriptor to read from. To make it work, we may use process substitution. |