why piping pwd and echo does not work? [duplicate]
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
This question already has an answer here:
Why doesn't text piped into an echo get outputted? [duplicate]
1 answer
Redirecting the content of a file to the command âechoâ
5 answers
I'm new to unix. I typed this command in ubuntu terminal:
pwd | echo
I expected to see the output of pwd
in terminal(/home/fatemeh/Documents/Code/test
)
but the output was just a single empty line.
why this happens?
command-line gnome-terminal echo pwd
marked as duplicate by G-Man, Kusalananda, roaima, Community⦠Jul 27 at 15:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
2
down vote
favorite
This question already has an answer here:
Why doesn't text piped into an echo get outputted? [duplicate]
1 answer
Redirecting the content of a file to the command âechoâ
5 answers
I'm new to unix. I typed this command in ubuntu terminal:
pwd | echo
I expected to see the output of pwd
in terminal(/home/fatemeh/Documents/Code/test
)
but the output was just a single empty line.
why this happens?
command-line gnome-terminal echo pwd
marked as duplicate by G-Man, Kusalananda, roaima, Community⦠Jul 27 at 15:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
This question already has an answer here:
Why doesn't text piped into an echo get outputted? [duplicate]
1 answer
Redirecting the content of a file to the command âechoâ
5 answers
I'm new to unix. I typed this command in ubuntu terminal:
pwd | echo
I expected to see the output of pwd
in terminal(/home/fatemeh/Documents/Code/test
)
but the output was just a single empty line.
why this happens?
command-line gnome-terminal echo pwd
This question already has an answer here:
Why doesn't text piped into an echo get outputted? [duplicate]
1 answer
Redirecting the content of a file to the command âechoâ
5 answers
I'm new to unix. I typed this command in ubuntu terminal:
pwd | echo
I expected to see the output of pwd
in terminal(/home/fatemeh/Documents/Code/test
)
but the output was just a single empty line.
why this happens?
This question already has an answer here:
Why doesn't text piped into an echo get outputted? [duplicate]
1 answer
Redirecting the content of a file to the command âechoâ
5 answers
command-line gnome-terminal echo pwd
asked Jul 27 at 15:06
Fatemeh Karimi
1154
1154
marked as duplicate by G-Man, Kusalananda, roaima, Community⦠Jul 27 at 15:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by G-Man, Kusalananda, roaima, Community⦠Jul 27 at 15:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
5
down vote
accepted
echo
does not do anything with standard input; it only parses its parameters. So you are effectively running echo
which, by itself, outputs a single empty line, and the standard input is discarded.
If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat
:
$ pwd | cat
/home/username
If you really want to use echo
to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:
$ echo "Your shell is currently working in '$(pwd)'."
Your shell is currently working in '/home/username'.
add a comment |Â
up vote
2
down vote
As is stated in the other answers, echo
does not read from stdin so it will not print the output of pwd
. Just in case you don't know already, pwd
prints it's output on it's own so you simply need to run it alone to get your desired result.
$ pwd
/current/working/dir
If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd
) to echo
as a parameter. Which again in this example is not necessary as pwd
will output it's own...output to stdout.
$ echo "$(pwd)"
/current/working/dir
add a comment |Â
up vote
1
down vote
The echo
command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo
is equivalent to just running echo
.
If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat
):
$ pwd | cat
/path/to/current/directory
$
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
echo
does not do anything with standard input; it only parses its parameters. So you are effectively running echo
which, by itself, outputs a single empty line, and the standard input is discarded.
If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat
:
$ pwd | cat
/home/username
If you really want to use echo
to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:
$ echo "Your shell is currently working in '$(pwd)'."
Your shell is currently working in '/home/username'.
add a comment |Â
up vote
5
down vote
accepted
echo
does not do anything with standard input; it only parses its parameters. So you are effectively running echo
which, by itself, outputs a single empty line, and the standard input is discarded.
If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat
:
$ pwd | cat
/home/username
If you really want to use echo
to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:
$ echo "Your shell is currently working in '$(pwd)'."
Your shell is currently working in '/home/username'.
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
echo
does not do anything with standard input; it only parses its parameters. So you are effectively running echo
which, by itself, outputs a single empty line, and the standard input is discarded.
If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat
:
$ pwd | cat
/home/username
If you really want to use echo
to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:
$ echo "Your shell is currently working in '$(pwd)'."
Your shell is currently working in '/home/username'.
echo
does not do anything with standard input; it only parses its parameters. So you are effectively running echo
which, by itself, outputs a single empty line, and the standard input is discarded.
If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat
:
$ pwd | cat
/home/username
If you really want to use echo
to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:
$ echo "Your shell is currently working in '$(pwd)'."
Your shell is currently working in '/home/username'.
edited Jul 27 at 17:56
answered Jul 27 at 15:08
DopeGhoti
39.5k54679
39.5k54679
add a comment |Â
add a comment |Â
up vote
2
down vote
As is stated in the other answers, echo
does not read from stdin so it will not print the output of pwd
. Just in case you don't know already, pwd
prints it's output on it's own so you simply need to run it alone to get your desired result.
$ pwd
/current/working/dir
If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd
) to echo
as a parameter. Which again in this example is not necessary as pwd
will output it's own...output to stdout.
$ echo "$(pwd)"
/current/working/dir
add a comment |Â
up vote
2
down vote
As is stated in the other answers, echo
does not read from stdin so it will not print the output of pwd
. Just in case you don't know already, pwd
prints it's output on it's own so you simply need to run it alone to get your desired result.
$ pwd
/current/working/dir
If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd
) to echo
as a parameter. Which again in this example is not necessary as pwd
will output it's own...output to stdout.
$ echo "$(pwd)"
/current/working/dir
add a comment |Â
up vote
2
down vote
up vote
2
down vote
As is stated in the other answers, echo
does not read from stdin so it will not print the output of pwd
. Just in case you don't know already, pwd
prints it's output on it's own so you simply need to run it alone to get your desired result.
$ pwd
/current/working/dir
If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd
) to echo
as a parameter. Which again in this example is not necessary as pwd
will output it's own...output to stdout.
$ echo "$(pwd)"
/current/working/dir
As is stated in the other answers, echo
does not read from stdin so it will not print the output of pwd
. Just in case you don't know already, pwd
prints it's output on it's own so you simply need to run it alone to get your desired result.
$ pwd
/current/working/dir
If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd
) to echo
as a parameter. Which again in this example is not necessary as pwd
will output it's own...output to stdout.
$ echo "$(pwd)"
/current/working/dir
answered Jul 27 at 15:14
Jesse_b
10.1k12658
10.1k12658
add a comment |Â
add a comment |Â
up vote
1
down vote
The echo
command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo
is equivalent to just running echo
.
If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat
):
$ pwd | cat
/path/to/current/directory
$
add a comment |Â
up vote
1
down vote
The echo
command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo
is equivalent to just running echo
.
If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat
):
$ pwd | cat
/path/to/current/directory
$
add a comment |Â
up vote
1
down vote
up vote
1
down vote
The echo
command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo
is equivalent to just running echo
.
If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat
):
$ pwd | cat
/path/to/current/directory
$
The echo
command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo
is equivalent to just running echo
.
If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat
):
$ pwd | cat
/path/to/current/directory
$
answered Jul 27 at 15:08
Andy Dalton
4,6911520
4,6911520
add a comment |Â
add a comment |Â