forked from kchandan/bash-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathredirect.sh
More file actions
53 lines (34 loc) · 971 Bytes
/
redirect.sh
File metadata and controls
53 lines (34 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
##Note that the file descriptor 0 is normally standard input (STDIN), 1 is standard output (STDOUT), and 2 is standard error output (STDERR).
echo Just '>' ---------------------------------------
find /etc -name grub >grub.out
echo Doing '2>' ---------------------------------------
find /etc -name grub 2>errs.out
echo Doing '&>' ---------------------------------------
find /etc -name grub &>both.out
pgm > file
Output of pgm is redirected to file
2
pgm < file
Program pgm reads its input from file
3
pgm >> file
Output of pgm is appended to file
4
n > file
Output from stream with descriptor n redirected to file
5
n >> file
Output from stream with descriptor n appended to file
6
n >& m
Merges output from stream n with stream m
7
n <& m
Merges input from stream n with stream m
8
<< tag
Standard input comes from here through next tag at the start of line
9
|
Takes output from one program, or process, and sends it to another