Autosave: 2022-12-11 19:00:05

This commit is contained in:
thomasabishop 2022-12-11 19:00:05 +00:00
parent 45920ddaba
commit 06e81d5a09
3 changed files with 15 additions and 0 deletions

View file

@ -18,6 +18,12 @@ This is a redirection statement. It is redirecting data to the `null` device on
The `2>&1` argument is the content: any errors that the program may generate and try to show in stout. Notice we are using the [file descriptors](/Programming_Languages/Shell/File_descriptors_and_redirection.md) `1` and `2`.
If you just want the errors regardless of whether they appear in `stdout` you do:
```bash
[some_command] > /dev/null 2>
```
## Example
I have used this in my Mongo start-up script:

View file

@ -21,6 +21,12 @@ It is common practice to combine redirection with the [file descriptors](/Progra
## Redirecting inputs
We can also switch the direction of the redirection symbol and pass in a file to a command rather than command ouput to a file:
```bash
sql-processing-program < data.sql
```
## Appending
We use `>>` to append contents on the next available line of a pre-existing file. Continuing on from the example above:

View file

@ -0,0 +1,3 @@
#!/bin/bash
find / -type f > list_of_files.list