We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a5af420 commit 8f01a84Copy full SHA for 8f01a84
bash/dev_null
@@ -0,0 +1,21 @@
1
+#!/usr/bin/env bash
2
+
3
+# stdin ==> fd 0
4
+# stdout ==> fd 1
5
+# stderr ==> fd 2
6
7
8
+# the following commands all send stdout and stderr to /dev/null
9
10
+# explicit
11
+rm nonexisting.txt 1> /dev/null 2> /dev/null
12
13
+# fd 1 is the default stdout, so it can be ommited
14
+rm nonexisting.txt > /dev/null 2> /dev/null
15
16
+# use a file descriptor duplication (>& 1) since /dev/null is already pointed
17
+# to by stdout 1
18
+rm nonexisting.txt 1> /dev/null 2>& 1
19
20
+# shortened form of the common operation
21
+rm nonexisting.txt &> /dev/null
0 commit comments