How can I know if a command works with pipe?
up vote
2
down vote
favorite
I saw this command:
docker inspect --format '{{.State.Running}}' $(docker ps -lq)
and this:
docker ps -l -q|while read cid b; do docker inspect -f '{{ .State.Running }}' $cid; done;
My question is why it cannot be written as:
docker ps -l -q|docker inspect -f '{{.State.Running}}'
If that was because docker inspect
does not work with pipe, how can I know which command can and which cannot?
pipe docker
add a comment |
up vote
2
down vote
favorite
I saw this command:
docker inspect --format '{{.State.Running}}' $(docker ps -lq)
and this:
docker ps -l -q|while read cid b; do docker inspect -f '{{ .State.Running }}' $cid; done;
My question is why it cannot be written as:
docker ps -l -q|docker inspect -f '{{.State.Running}}'
If that was because docker inspect
does not work with pipe, how can I know which command can and which cannot?
pipe docker
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I saw this command:
docker inspect --format '{{.State.Running}}' $(docker ps -lq)
and this:
docker ps -l -q|while read cid b; do docker inspect -f '{{ .State.Running }}' $cid; done;
My question is why it cannot be written as:
docker ps -l -q|docker inspect -f '{{.State.Running}}'
If that was because docker inspect
does not work with pipe, how can I know which command can and which cannot?
pipe docker
I saw this command:
docker inspect --format '{{.State.Running}}' $(docker ps -lq)
and this:
docker ps -l -q|while read cid b; do docker inspect -f '{{ .State.Running }}' $cid; done;
My question is why it cannot be written as:
docker ps -l -q|docker inspect -f '{{.State.Running}}'
If that was because docker inspect
does not work with pipe, how can I know which command can and which cannot?
pipe docker
pipe docker
edited Nov 25 at 15:00
Rui F Ribeiro
38.3k1475126
38.3k1475126
asked Oct 2 '15 at 10:59
Xiao Peng - ZenUML.com
1214
1214
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
Pipe takes the output of the first program and passes it into the next program. In a sense, it pretends to be a user typing input into the second program in a terminal. So, if you can run the program and type in (for example) a list of files to operate on while the program is running, then you can do the same thing with a pipe.
You may see hints to what can be done using pipes in a program's manual. For instance, man wget
mentions the -i
argument, and that -i -
will read files from standard input, also called STDIN. So you could cat list-of-links.txt | wget -i -
, or more effectively wget -i - < list-of-links.txt
.
A caveat to this is that some programs acts differently when the input comes from or goes to a pipe, compared from when connected to a terminal.
– Kusalananda
Nov 25 at 15:03
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Pipe takes the output of the first program and passes it into the next program. In a sense, it pretends to be a user typing input into the second program in a terminal. So, if you can run the program and type in (for example) a list of files to operate on while the program is running, then you can do the same thing with a pipe.
You may see hints to what can be done using pipes in a program's manual. For instance, man wget
mentions the -i
argument, and that -i -
will read files from standard input, also called STDIN. So you could cat list-of-links.txt | wget -i -
, or more effectively wget -i - < list-of-links.txt
.
A caveat to this is that some programs acts differently when the input comes from or goes to a pipe, compared from when connected to a terminal.
– Kusalananda
Nov 25 at 15:03
add a comment |
up vote
2
down vote
Pipe takes the output of the first program and passes it into the next program. In a sense, it pretends to be a user typing input into the second program in a terminal. So, if you can run the program and type in (for example) a list of files to operate on while the program is running, then you can do the same thing with a pipe.
You may see hints to what can be done using pipes in a program's manual. For instance, man wget
mentions the -i
argument, and that -i -
will read files from standard input, also called STDIN. So you could cat list-of-links.txt | wget -i -
, or more effectively wget -i - < list-of-links.txt
.
A caveat to this is that some programs acts differently when the input comes from or goes to a pipe, compared from when connected to a terminal.
– Kusalananda
Nov 25 at 15:03
add a comment |
up vote
2
down vote
up vote
2
down vote
Pipe takes the output of the first program and passes it into the next program. In a sense, it pretends to be a user typing input into the second program in a terminal. So, if you can run the program and type in (for example) a list of files to operate on while the program is running, then you can do the same thing with a pipe.
You may see hints to what can be done using pipes in a program's manual. For instance, man wget
mentions the -i
argument, and that -i -
will read files from standard input, also called STDIN. So you could cat list-of-links.txt | wget -i -
, or more effectively wget -i - < list-of-links.txt
.
Pipe takes the output of the first program and passes it into the next program. In a sense, it pretends to be a user typing input into the second program in a terminal. So, if you can run the program and type in (for example) a list of files to operate on while the program is running, then you can do the same thing with a pipe.
You may see hints to what can be done using pipes in a program's manual. For instance, man wget
mentions the -i
argument, and that -i -
will read files from standard input, also called STDIN. So you could cat list-of-links.txt | wget -i -
, or more effectively wget -i - < list-of-links.txt
.
answered Oct 2 '15 at 11:25
tripflag
43524
43524
A caveat to this is that some programs acts differently when the input comes from or goes to a pipe, compared from when connected to a terminal.
– Kusalananda
Nov 25 at 15:03
add a comment |
A caveat to this is that some programs acts differently when the input comes from or goes to a pipe, compared from when connected to a terminal.
– Kusalananda
Nov 25 at 15:03
A caveat to this is that some programs acts differently when the input comes from or goes to a pipe, compared from when connected to a terminal.
– Kusalananda
Nov 25 at 15:03
A caveat to this is that some programs acts differently when the input comes from or goes to a pipe, compared from when connected to a terminal.
– Kusalananda
Nov 25 at 15:03
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f233470%2fhow-can-i-know-if-a-command-works-with-pipe%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown