Why can't I pipe `pwd` to `open` on macOS?
Clash Royale CLAN TAG#URR8PPP
up vote
12
down vote
favorite
This is macOS specific, but seems too unixy to go in the Ask Different community.
In Terminal, I can pwd
, copy the result, and type open
and paste the result and the folder will open in the Finder, but
pwd | open
prints the help documentation for open
. Why doesn't piping work but pasting does?
osx pipe
add a comment |Â
up vote
12
down vote
favorite
This is macOS specific, but seems too unixy to go in the Ask Different community.
In Terminal, I can pwd
, copy the result, and type open
and paste the result and the folder will open in the Finder, but
pwd | open
prints the help documentation for open
. Why doesn't piping work but pasting does?
osx pipe
that will only work if open expects you to type the directory name after you press enter.
â Jasen
Jul 23 '16 at 4:32
8
Also, this should (not a mac user) work:open .
(for the current directory)
â UniversallyUniqueID
Jul 23 '16 at 10:44
@BharadwajRajuopen .
works and does seem the easiest. ty.
â Chuck
Jul 23 '16 at 13:00
add a comment |Â
up vote
12
down vote
favorite
up vote
12
down vote
favorite
This is macOS specific, but seems too unixy to go in the Ask Different community.
In Terminal, I can pwd
, copy the result, and type open
and paste the result and the folder will open in the Finder, but
pwd | open
prints the help documentation for open
. Why doesn't piping work but pasting does?
osx pipe
This is macOS specific, but seems too unixy to go in the Ask Different community.
In Terminal, I can pwd
, copy the result, and type open
and paste the result and the folder will open in the Finder, but
pwd | open
prints the help documentation for open
. Why doesn't piping work but pasting does?
osx pipe
osx pipe
edited Apr 13 '17 at 12:45
Communityâ¦
1
1
asked Jul 23 '16 at 4:04
Chuck
255111
255111
that will only work if open expects you to type the directory name after you press enter.
â Jasen
Jul 23 '16 at 4:32
8
Also, this should (not a mac user) work:open .
(for the current directory)
â UniversallyUniqueID
Jul 23 '16 at 10:44
@BharadwajRajuopen .
works and does seem the easiest. ty.
â Chuck
Jul 23 '16 at 13:00
add a comment |Â
that will only work if open expects you to type the directory name after you press enter.
â Jasen
Jul 23 '16 at 4:32
8
Also, this should (not a mac user) work:open .
(for the current directory)
â UniversallyUniqueID
Jul 23 '16 at 10:44
@BharadwajRajuopen .
works and does seem the easiest. ty.
â Chuck
Jul 23 '16 at 13:00
that will only work if open expects you to type the directory name after you press enter.
â Jasen
Jul 23 '16 at 4:32
that will only work if open expects you to type the directory name after you press enter.
â Jasen
Jul 23 '16 at 4:32
8
8
Also, this should (not a mac user) work:
open .
(for the current directory)â UniversallyUniqueID
Jul 23 '16 at 10:44
Also, this should (not a mac user) work:
open .
(for the current directory)â UniversallyUniqueID
Jul 23 '16 at 10:44
@BharadwajRaju
open .
works and does seem the easiest. ty.â Chuck
Jul 23 '16 at 13:00
@BharadwajRaju
open .
works and does seem the easiest. ty.â Chuck
Jul 23 '16 at 13:00
add a comment |Â
5 Answers
5
active
oldest
votes
up vote
19
down vote
accepted
I don't have a Mac so I can't test it, but the solution should be something like:
open "`pwd`"
Not all programs take their input from stdin
which would be necessary for the pipe to work.
1
The double quotes are unnecessary.
â tbodt
Jul 23 '16 at 18:50
3
@tbodt: Try it in/var/tbodt's files
.
â Julie Pelletier
Jul 23 '16 at 19:00
I would have thought bash would treat that as one argument... This is why I don't use bash.
â tbodt
Jul 23 '16 at 19:04
2
@tbodt: How would any shell know if the space used is to separate arguments or part of an argument?
â Julie Pelletier
Jul 23 '16 at 19:06
2
@jamesdlin: Go complain on thebash
development project, but don't forget to also go bash all older shells and most newer shells while you're at it. Over and out!
â Julie Pelletier
Jul 23 '16 at 19:34
 |Â
show 5 more comments
up vote
26
down vote
The open
utility on Mac does not read from standard input, but take its arguments from the command line.
To open the current working directory, you would have to say
$ open "$( pwd )"
or
$ open "$PWD"
or simply
$ open .
as pointed out in the comments below.
With the -f
flag, open
can be made to read from standard input, but only to open whatever it receives in the default text editor.
1
If the shell is (t)csh, you'd wantopen $cwd:q
instead. Andopen (pwd)
/open $PWD
if it'sfish
â Stéphane Chazelas
Jul 23 '16 at 7:46
1
@StéphaneChazelas I believe the default shell on Darwin isbash
, but it's always good to see solutions for other shells too.
â Kusalananda
Jul 23 '16 at 7:55
For completeness, withrc
,es
,akanga
shells:open `pwd
oropen `pwd
â Stéphane Chazelas
Jul 23 '16 at 10:19
4
Or you can use the syntax-open .
for the current working directory or the parent directoryopen ..
or up two directoriesopen ../..
and so forth.
â fd0
Jul 23 '16 at 10:46
@StéphaneChazelas: Why would$cwd:q
be preferable to"$cwd"
in a csh-related shell?
â G-Man
Jul 24 '16 at 2:18
 |Â
show 1 more comment
up vote
10
down vote
The other answers are totally correct. If you want an easy shorthand, you can do as @fd0 proposed, and just use
open .
to open the current directory. The current directory is named .
(a single dot) in Unix, the parent directory ..
(two dots).
add a comment |Â
up vote
6
down vote
pwd | xargs open
xargs
shoves its standart input into the arguments of its first argument.
1
That's only if the current working directory path doesn't contain blanks or newline or single quotes or double quotes or backslashes.
â Stéphane Chazelas
Jul 24 '16 at 4:06
add a comment |Â
up vote
0
down vote
You can use a pipeline with -f
to open the content of the previous command in a Text Editor. This just applies for text editors. For other apps you'll need to use the suggestion in the other questions.
For example:
ls | open -f
This would open your default text editor with the ls
output content.
You can also specify the text editor to use using -a
:
ls | open -a 'Atom' -f
This would open Atom with the ls
output content.
New contributor
add a comment |Â
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
19
down vote
accepted
I don't have a Mac so I can't test it, but the solution should be something like:
open "`pwd`"
Not all programs take their input from stdin
which would be necessary for the pipe to work.
1
The double quotes are unnecessary.
â tbodt
Jul 23 '16 at 18:50
3
@tbodt: Try it in/var/tbodt's files
.
â Julie Pelletier
Jul 23 '16 at 19:00
I would have thought bash would treat that as one argument... This is why I don't use bash.
â tbodt
Jul 23 '16 at 19:04
2
@tbodt: How would any shell know if the space used is to separate arguments or part of an argument?
â Julie Pelletier
Jul 23 '16 at 19:06
2
@jamesdlin: Go complain on thebash
development project, but don't forget to also go bash all older shells and most newer shells while you're at it. Over and out!
â Julie Pelletier
Jul 23 '16 at 19:34
 |Â
show 5 more comments
up vote
19
down vote
accepted
I don't have a Mac so I can't test it, but the solution should be something like:
open "`pwd`"
Not all programs take their input from stdin
which would be necessary for the pipe to work.
1
The double quotes are unnecessary.
â tbodt
Jul 23 '16 at 18:50
3
@tbodt: Try it in/var/tbodt's files
.
â Julie Pelletier
Jul 23 '16 at 19:00
I would have thought bash would treat that as one argument... This is why I don't use bash.
â tbodt
Jul 23 '16 at 19:04
2
@tbodt: How would any shell know if the space used is to separate arguments or part of an argument?
â Julie Pelletier
Jul 23 '16 at 19:06
2
@jamesdlin: Go complain on thebash
development project, but don't forget to also go bash all older shells and most newer shells while you're at it. Over and out!
â Julie Pelletier
Jul 23 '16 at 19:34
 |Â
show 5 more comments
up vote
19
down vote
accepted
up vote
19
down vote
accepted
I don't have a Mac so I can't test it, but the solution should be something like:
open "`pwd`"
Not all programs take their input from stdin
which would be necessary for the pipe to work.
I don't have a Mac so I can't test it, but the solution should be something like:
open "`pwd`"
Not all programs take their input from stdin
which would be necessary for the pipe to work.
edited Jul 23 '16 at 7:39
answered Jul 23 '16 at 4:08
Julie Pelletier
6,91211239
6,91211239
1
The double quotes are unnecessary.
â tbodt
Jul 23 '16 at 18:50
3
@tbodt: Try it in/var/tbodt's files
.
â Julie Pelletier
Jul 23 '16 at 19:00
I would have thought bash would treat that as one argument... This is why I don't use bash.
â tbodt
Jul 23 '16 at 19:04
2
@tbodt: How would any shell know if the space used is to separate arguments or part of an argument?
â Julie Pelletier
Jul 23 '16 at 19:06
2
@jamesdlin: Go complain on thebash
development project, but don't forget to also go bash all older shells and most newer shells while you're at it. Over and out!
â Julie Pelletier
Jul 23 '16 at 19:34
 |Â
show 5 more comments
1
The double quotes are unnecessary.
â tbodt
Jul 23 '16 at 18:50
3
@tbodt: Try it in/var/tbodt's files
.
â Julie Pelletier
Jul 23 '16 at 19:00
I would have thought bash would treat that as one argument... This is why I don't use bash.
â tbodt
Jul 23 '16 at 19:04
2
@tbodt: How would any shell know if the space used is to separate arguments or part of an argument?
â Julie Pelletier
Jul 23 '16 at 19:06
2
@jamesdlin: Go complain on thebash
development project, but don't forget to also go bash all older shells and most newer shells while you're at it. Over and out!
â Julie Pelletier
Jul 23 '16 at 19:34
1
1
The double quotes are unnecessary.
â tbodt
Jul 23 '16 at 18:50
The double quotes are unnecessary.
â tbodt
Jul 23 '16 at 18:50
3
3
@tbodt: Try it in
/var/tbodt's files
.â Julie Pelletier
Jul 23 '16 at 19:00
@tbodt: Try it in
/var/tbodt's files
.â Julie Pelletier
Jul 23 '16 at 19:00
I would have thought bash would treat that as one argument... This is why I don't use bash.
â tbodt
Jul 23 '16 at 19:04
I would have thought bash would treat that as one argument... This is why I don't use bash.
â tbodt
Jul 23 '16 at 19:04
2
2
@tbodt: How would any shell know if the space used is to separate arguments or part of an argument?
â Julie Pelletier
Jul 23 '16 at 19:06
@tbodt: How would any shell know if the space used is to separate arguments or part of an argument?
â Julie Pelletier
Jul 23 '16 at 19:06
2
2
@jamesdlin: Go complain on the
bash
development project, but don't forget to also go bash all older shells and most newer shells while you're at it. Over and out!â Julie Pelletier
Jul 23 '16 at 19:34
@jamesdlin: Go complain on the
bash
development project, but don't forget to also go bash all older shells and most newer shells while you're at it. Over and out!â Julie Pelletier
Jul 23 '16 at 19:34
 |Â
show 5 more comments
up vote
26
down vote
The open
utility on Mac does not read from standard input, but take its arguments from the command line.
To open the current working directory, you would have to say
$ open "$( pwd )"
or
$ open "$PWD"
or simply
$ open .
as pointed out in the comments below.
With the -f
flag, open
can be made to read from standard input, but only to open whatever it receives in the default text editor.
1
If the shell is (t)csh, you'd wantopen $cwd:q
instead. Andopen (pwd)
/open $PWD
if it'sfish
â Stéphane Chazelas
Jul 23 '16 at 7:46
1
@StéphaneChazelas I believe the default shell on Darwin isbash
, but it's always good to see solutions for other shells too.
â Kusalananda
Jul 23 '16 at 7:55
For completeness, withrc
,es
,akanga
shells:open `pwd
oropen `pwd
â Stéphane Chazelas
Jul 23 '16 at 10:19
4
Or you can use the syntax-open .
for the current working directory or the parent directoryopen ..
or up two directoriesopen ../..
and so forth.
â fd0
Jul 23 '16 at 10:46
@StéphaneChazelas: Why would$cwd:q
be preferable to"$cwd"
in a csh-related shell?
â G-Man
Jul 24 '16 at 2:18
 |Â
show 1 more comment
up vote
26
down vote
The open
utility on Mac does not read from standard input, but take its arguments from the command line.
To open the current working directory, you would have to say
$ open "$( pwd )"
or
$ open "$PWD"
or simply
$ open .
as pointed out in the comments below.
With the -f
flag, open
can be made to read from standard input, but only to open whatever it receives in the default text editor.
1
If the shell is (t)csh, you'd wantopen $cwd:q
instead. Andopen (pwd)
/open $PWD
if it'sfish
â Stéphane Chazelas
Jul 23 '16 at 7:46
1
@StéphaneChazelas I believe the default shell on Darwin isbash
, but it's always good to see solutions for other shells too.
â Kusalananda
Jul 23 '16 at 7:55
For completeness, withrc
,es
,akanga
shells:open `pwd
oropen `pwd
â Stéphane Chazelas
Jul 23 '16 at 10:19
4
Or you can use the syntax-open .
for the current working directory or the parent directoryopen ..
or up two directoriesopen ../..
and so forth.
â fd0
Jul 23 '16 at 10:46
@StéphaneChazelas: Why would$cwd:q
be preferable to"$cwd"
in a csh-related shell?
â G-Man
Jul 24 '16 at 2:18
 |Â
show 1 more comment
up vote
26
down vote
up vote
26
down vote
The open
utility on Mac does not read from standard input, but take its arguments from the command line.
To open the current working directory, you would have to say
$ open "$( pwd )"
or
$ open "$PWD"
or simply
$ open .
as pointed out in the comments below.
With the -f
flag, open
can be made to read from standard input, but only to open whatever it receives in the default text editor.
The open
utility on Mac does not read from standard input, but take its arguments from the command line.
To open the current working directory, you would have to say
$ open "$( pwd )"
or
$ open "$PWD"
or simply
$ open .
as pointed out in the comments below.
With the -f
flag, open
can be made to read from standard input, but only to open whatever it receives in the default text editor.
edited Jul 23 '16 at 11:48
answered Jul 23 '16 at 6:15
Kusalananda
109k14211334
109k14211334
1
If the shell is (t)csh, you'd wantopen $cwd:q
instead. Andopen (pwd)
/open $PWD
if it'sfish
â Stéphane Chazelas
Jul 23 '16 at 7:46
1
@StéphaneChazelas I believe the default shell on Darwin isbash
, but it's always good to see solutions for other shells too.
â Kusalananda
Jul 23 '16 at 7:55
For completeness, withrc
,es
,akanga
shells:open `pwd
oropen `pwd
â Stéphane Chazelas
Jul 23 '16 at 10:19
4
Or you can use the syntax-open .
for the current working directory or the parent directoryopen ..
or up two directoriesopen ../..
and so forth.
â fd0
Jul 23 '16 at 10:46
@StéphaneChazelas: Why would$cwd:q
be preferable to"$cwd"
in a csh-related shell?
â G-Man
Jul 24 '16 at 2:18
 |Â
show 1 more comment
1
If the shell is (t)csh, you'd wantopen $cwd:q
instead. Andopen (pwd)
/open $PWD
if it'sfish
â Stéphane Chazelas
Jul 23 '16 at 7:46
1
@StéphaneChazelas I believe the default shell on Darwin isbash
, but it's always good to see solutions for other shells too.
â Kusalananda
Jul 23 '16 at 7:55
For completeness, withrc
,es
,akanga
shells:open `pwd
oropen `pwd
â Stéphane Chazelas
Jul 23 '16 at 10:19
4
Or you can use the syntax-open .
for the current working directory or the parent directoryopen ..
or up two directoriesopen ../..
and so forth.
â fd0
Jul 23 '16 at 10:46
@StéphaneChazelas: Why would$cwd:q
be preferable to"$cwd"
in a csh-related shell?
â G-Man
Jul 24 '16 at 2:18
1
1
If the shell is (t)csh, you'd want
open $cwd:q
instead. And open (pwd)
/open $PWD
if it's fish
â Stéphane Chazelas
Jul 23 '16 at 7:46
If the shell is (t)csh, you'd want
open $cwd:q
instead. And open (pwd)
/open $PWD
if it's fish
â Stéphane Chazelas
Jul 23 '16 at 7:46
1
1
@StéphaneChazelas I believe the default shell on Darwin is
bash
, but it's always good to see solutions for other shells too.â Kusalananda
Jul 23 '16 at 7:55
@StéphaneChazelas I believe the default shell on Darwin is
bash
, but it's always good to see solutions for other shells too.â Kusalananda
Jul 23 '16 at 7:55
For completeness, with
rc
, es
, akanga
shells: open `pwd
or open `pwd
â Stéphane Chazelas
Jul 23 '16 at 10:19
For completeness, with
rc
, es
, akanga
shells: open `pwd
or open `pwd
â Stéphane Chazelas
Jul 23 '16 at 10:19
4
4
Or you can use the syntax-
open .
for the current working directory or the parent directory open ..
or up two directories open ../..
and so forth.â fd0
Jul 23 '16 at 10:46
Or you can use the syntax-
open .
for the current working directory or the parent directory open ..
or up two directories open ../..
and so forth.â fd0
Jul 23 '16 at 10:46
@StéphaneChazelas: Why would
$cwd:q
be preferable to "$cwd"
in a csh-related shell?â G-Man
Jul 24 '16 at 2:18
@StéphaneChazelas: Why would
$cwd:q
be preferable to "$cwd"
in a csh-related shell?â G-Man
Jul 24 '16 at 2:18
 |Â
show 1 more comment
up vote
10
down vote
The other answers are totally correct. If you want an easy shorthand, you can do as @fd0 proposed, and just use
open .
to open the current directory. The current directory is named .
(a single dot) in Unix, the parent directory ..
(two dots).
add a comment |Â
up vote
10
down vote
The other answers are totally correct. If you want an easy shorthand, you can do as @fd0 proposed, and just use
open .
to open the current directory. The current directory is named .
(a single dot) in Unix, the parent directory ..
(two dots).
add a comment |Â
up vote
10
down vote
up vote
10
down vote
The other answers are totally correct. If you want an easy shorthand, you can do as @fd0 proposed, and just use
open .
to open the current directory. The current directory is named .
(a single dot) in Unix, the parent directory ..
(two dots).
The other answers are totally correct. If you want an easy shorthand, you can do as @fd0 proposed, and just use
open .
to open the current directory. The current directory is named .
(a single dot) in Unix, the parent directory ..
(two dots).
edited Apr 13 '17 at 12:36
Communityâ¦
1
1
answered Jul 23 '16 at 10:57
serv-inc
404212
404212
add a comment |Â
add a comment |Â
up vote
6
down vote
pwd | xargs open
xargs
shoves its standart input into the arguments of its first argument.
1
That's only if the current working directory path doesn't contain blanks or newline or single quotes or double quotes or backslashes.
â Stéphane Chazelas
Jul 24 '16 at 4:06
add a comment |Â
up vote
6
down vote
pwd | xargs open
xargs
shoves its standart input into the arguments of its first argument.
1
That's only if the current working directory path doesn't contain blanks or newline or single quotes or double quotes or backslashes.
â Stéphane Chazelas
Jul 24 '16 at 4:06
add a comment |Â
up vote
6
down vote
up vote
6
down vote
pwd | xargs open
xargs
shoves its standart input into the arguments of its first argument.
pwd | xargs open
xargs
shoves its standart input into the arguments of its first argument.
answered Jul 23 '16 at 20:52
dbanet
1245
1245
1
That's only if the current working directory path doesn't contain blanks or newline or single quotes or double quotes or backslashes.
â Stéphane Chazelas
Jul 24 '16 at 4:06
add a comment |Â
1
That's only if the current working directory path doesn't contain blanks or newline or single quotes or double quotes or backslashes.
â Stéphane Chazelas
Jul 24 '16 at 4:06
1
1
That's only if the current working directory path doesn't contain blanks or newline or single quotes or double quotes or backslashes.
â Stéphane Chazelas
Jul 24 '16 at 4:06
That's only if the current working directory path doesn't contain blanks or newline or single quotes or double quotes or backslashes.
â Stéphane Chazelas
Jul 24 '16 at 4:06
add a comment |Â
up vote
0
down vote
You can use a pipeline with -f
to open the content of the previous command in a Text Editor. This just applies for text editors. For other apps you'll need to use the suggestion in the other questions.
For example:
ls | open -f
This would open your default text editor with the ls
output content.
You can also specify the text editor to use using -a
:
ls | open -a 'Atom' -f
This would open Atom with the ls
output content.
New contributor
add a comment |Â
up vote
0
down vote
You can use a pipeline with -f
to open the content of the previous command in a Text Editor. This just applies for text editors. For other apps you'll need to use the suggestion in the other questions.
For example:
ls | open -f
This would open your default text editor with the ls
output content.
You can also specify the text editor to use using -a
:
ls | open -a 'Atom' -f
This would open Atom with the ls
output content.
New contributor
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You can use a pipeline with -f
to open the content of the previous command in a Text Editor. This just applies for text editors. For other apps you'll need to use the suggestion in the other questions.
For example:
ls | open -f
This would open your default text editor with the ls
output content.
You can also specify the text editor to use using -a
:
ls | open -a 'Atom' -f
This would open Atom with the ls
output content.
New contributor
You can use a pipeline with -f
to open the content of the previous command in a Text Editor. This just applies for text editors. For other apps you'll need to use the suggestion in the other questions.
For example:
ls | open -f
This would open your default text editor with the ls
output content.
You can also specify the text editor to use using -a
:
ls | open -a 'Atom' -f
This would open Atom with the ls
output content.
New contributor
New contributor
answered 10 hours ago
Pau Chorro
1012
1012
New contributor
New contributor
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f297729%2fwhy-cant-i-pipe-pwd-to-open-on-macos%23new-answer', 'question_page');
);
Post as a guest
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
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
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
that will only work if open expects you to type the directory name after you press enter.
â Jasen
Jul 23 '16 at 4:32
8
Also, this should (not a mac user) work:
open .
(for the current directory)â UniversallyUniqueID
Jul 23 '16 at 10:44
@BharadwajRaju
open .
works and does seem the easiest. ty.â Chuck
Jul 23 '16 at 13:00