Skip to content

Commit

Permalink
added redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyloris committed Feb 26, 2024
1 parent 7aeef29 commit b90f3aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mergeFiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Merge MD Files
run: |
# Define the order of markdown files to merge
files_to_merge=("index.md", "navigation.md", "files.md", "ssh.md", "sed.md", "grep.md", "searchingFiles.md", "netstat.md", "lsof.md", "curl.md", "wget.md")
files_to_merge=("index.md", "navigation.md", "files.md", "ssh.md", "sed.md", "grep.md", "searchingFiles.md", "netstat.md", "lsof.md", "curl.md", "wget.md", "redirection.md")
# remove existing contents readme
echo '' > README.md
# Merge files in the specified order
Expand Down
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@


### Stuff you should to Know
1. [Redirection](#REDIRECTION)
1. [Redirection](#redirection)
2. [Process Substitution](#PROCESS_SUBSTITUTION)
3. [Bash Fu](#BASHFU)
17 changes: 17 additions & 0 deletions redirection.md
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.

0 comments on commit b90f3aa

Please sign in to comment.