From 06e81d5a09eb9073be07b1b0cbd609696d4570eb Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Sun, 11 Dec 2022 19:00:05 +0000 Subject: [PATCH] Autosave: 2022-12-11 19:00:05 --- Programming_Languages/Shell/Redirect_to_dev_null.md | 6 ++++++ Programming_Languages/Shell/Redirection.md | 6 ++++++ _scripts/random_revision_topic.sh | 3 +++ 3 files changed, 15 insertions(+) create mode 100644 _scripts/random_revision_topic.sh diff --git a/Programming_Languages/Shell/Redirect_to_dev_null.md b/Programming_Languages/Shell/Redirect_to_dev_null.md index 4a8d6af..3d31fd7 100644 --- a/Programming_Languages/Shell/Redirect_to_dev_null.md +++ b/Programming_Languages/Shell/Redirect_to_dev_null.md @@ -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: diff --git a/Programming_Languages/Shell/Redirection.md b/Programming_Languages/Shell/Redirection.md index 4b1f8bc..e784072 100644 --- a/Programming_Languages/Shell/Redirection.md +++ b/Programming_Languages/Shell/Redirection.md @@ -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: diff --git a/_scripts/random_revision_topic.sh b/_scripts/random_revision_topic.sh new file mode 100644 index 0000000..85e97d6 --- /dev/null +++ b/_scripts/random_revision_topic.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find / -type f > list_of_files.list \ No newline at end of file