Where does pipe send its output?
up vote
0
down vote
favorite
My understanding is that pipe
in e.g.,
command1 | command2
sends the output of the command1
to command2
. However, I would have expected this to work:
echo "tmp.pdf" | evince
But it does not. Where is the output of echo "tmp.pdf"
being sent?
pipe
add a comment |
up vote
0
down vote
favorite
My understanding is that pipe
in e.g.,
command1 | command2
sends the output of the command1
to command2
. However, I would have expected this to work:
echo "tmp.pdf" | evince
But it does not. Where is the output of echo "tmp.pdf"
being sent?
pipe
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My understanding is that pipe
in e.g.,
command1 | command2
sends the output of the command1
to command2
. However, I would have expected this to work:
echo "tmp.pdf" | evince
But it does not. Where is the output of echo "tmp.pdf"
being sent?
pipe
My understanding is that pipe
in e.g.,
command1 | command2
sends the output of the command1
to command2
. However, I would have expected this to work:
echo "tmp.pdf" | evince
But it does not. Where is the output of echo "tmp.pdf"
being sent?
pipe
pipe
edited Nov 25 at 22:50
Rui F Ribeiro
38.3k1477127
38.3k1477127
asked Jun 29 '15 at 13:29
JeffDror
16016
16016
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
5
down vote
accepted
A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince
in your example.
You're sending the file name tmp.pdf
to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.
Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf"
. (This may not work on all Unix variants.) The file name /dev/stdin
means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin
doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.
add a comment |
up vote
6
down vote
Your understanding is correct. The sequence command1 | command2
is sending the output (STDOUT) of command1
to the input (STDIN) of command2
. The reason your evince
command didn't work is that evince
doesn't accept a filename on STDIN.
add a comment |
up vote
0
down vote
You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
evince "$(sudo locate xyz | grep abc)"
.
Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
The reason why I am using another code (piped with sudo locate xyz
) i.e grep abc
is to further filter down the result.
But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb
. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
For instance you can do-
evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"
and pass this as an argument to evince.here argument -iname
is for case insensitive search and -a
is and condition. -type f
will only return files.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince
in your example.
You're sending the file name tmp.pdf
to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.
Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf"
. (This may not work on all Unix variants.) The file name /dev/stdin
means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin
doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.
add a comment |
up vote
5
down vote
accepted
A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince
in your example.
You're sending the file name tmp.pdf
to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.
Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf"
. (This may not work on all Unix variants.) The file name /dev/stdin
means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin
doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince
in your example.
You're sending the file name tmp.pdf
to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.
Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf"
. (This may not work on all Unix variants.) The file name /dev/stdin
means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin
doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.
A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince
in your example.
You're sending the file name tmp.pdf
to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.
Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf"
. (This may not work on all Unix variants.) The file name /dev/stdin
means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin
doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.
answered Jun 29 '15 at 23:49
Gilles
523k12610441576
523k12610441576
add a comment |
add a comment |
up vote
6
down vote
Your understanding is correct. The sequence command1 | command2
is sending the output (STDOUT) of command1
to the input (STDIN) of command2
. The reason your evince
command didn't work is that evince
doesn't accept a filename on STDIN.
add a comment |
up vote
6
down vote
Your understanding is correct. The sequence command1 | command2
is sending the output (STDOUT) of command1
to the input (STDIN) of command2
. The reason your evince
command didn't work is that evince
doesn't accept a filename on STDIN.
add a comment |
up vote
6
down vote
up vote
6
down vote
Your understanding is correct. The sequence command1 | command2
is sending the output (STDOUT) of command1
to the input (STDIN) of command2
. The reason your evince
command didn't work is that evince
doesn't accept a filename on STDIN.
Your understanding is correct. The sequence command1 | command2
is sending the output (STDOUT) of command1
to the input (STDIN) of command2
. The reason your evince
command didn't work is that evince
doesn't accept a filename on STDIN.
answered Jun 29 '15 at 13:31
John
11.4k11730
11.4k11730
add a comment |
add a comment |
up vote
0
down vote
You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
evince "$(sudo locate xyz | grep abc)"
.
Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
The reason why I am using another code (piped with sudo locate xyz
) i.e grep abc
is to further filter down the result.
But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb
. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
For instance you can do-
evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"
and pass this as an argument to evince.here argument -iname
is for case insensitive search and -a
is and condition. -type f
will only return files.
add a comment |
up vote
0
down vote
You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
evince "$(sudo locate xyz | grep abc)"
.
Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
The reason why I am using another code (piped with sudo locate xyz
) i.e grep abc
is to further filter down the result.
But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb
. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
For instance you can do-
evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"
and pass this as an argument to evince.here argument -iname
is for case insensitive search and -a
is and condition. -type f
will only return files.
add a comment |
up vote
0
down vote
up vote
0
down vote
You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
evince "$(sudo locate xyz | grep abc)"
.
Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
The reason why I am using another code (piped with sudo locate xyz
) i.e grep abc
is to further filter down the result.
But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb
. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
For instance you can do-
evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"
and pass this as an argument to evince.here argument -iname
is for case insensitive search and -a
is and condition. -type f
will only return files.
You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
evince "$(sudo locate xyz | grep abc)"
.
Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
The reason why I am using another code (piped with sudo locate xyz
) i.e grep abc
is to further filter down the result.
But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb
. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
For instance you can do-
evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"
and pass this as an argument to evince.here argument -iname
is for case insensitive search and -a
is and condition. -type f
will only return files.
edited Dec 17 '16 at 3:55
answered Dec 16 '16 at 10:52
Amardeep Mishra
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f212848%2fwhere-does-pipe-send-its-output%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