-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
pipes-standard-output-and-standard-input.scroll
40 lines (24 loc) · 1.26 KB
/
pipes-standard-output-and-standard-input.scroll
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
date 2010-0-26
tags index
permalink pipes-standard-output-and-standard-input.html
title Pipes, standard output and standard input
pageHeader.scroll
In linux, standard input refers to the stream of bits that come from your keyboard.
Standard output refers to the stream of bits that appear on your screen(terminal).
You can change this around so that standard input comes from another source(say, a file) or so that standard output gets directed somewhere else (say, a file).
For example, say we wanted to email someone a file containing the contents of our home directory. We could do this:
code
ls ~ | vim -
This will pipe the output from the ls command to vim. You can then edit and save this file normally as you would in vim.
There's another type of pipe you could use for this example: greater than.
code
ls ~ > contents.txt
This will redirect the output to the contents.txt file.
You can also append output by using two greater than signs:
code
ls ~ >> some_file.txt
As you would expect, the less than sign can be used to direct a file as standard in.
# Notes
- Linux <a href="https://www.amazon.com/Linux-Phrasebook-Granneman-Scott-Paperback/dp/B011DB5ZDQ">Phrasebook</a>
- <a href="https://ubuntuforums.org/showthread.php?t=713210">pipe</a> to vim
footer.scroll