Strange behaviour redirecting man pages
I wanted to redirect mc
's man page to a text file using man mc > mc
, but I accidentally executed man mc > mc grep
. What resulted was a text file named mc
containing two concatenated mc
man pages.
I then tried man ls > 1 abc
, which resulted in text file named 1
containing the ls
man page and an error message in the terminal: No manual entry for abc
.
Next I tried man du > du ls tac
. I expected three concatenated du
man pages, but what actually resulted was a text file named du
containing the man pages of du
, ls
and tac
concatenated.
Why did each command produced the results it did?
io-redirection man
add a comment |
I wanted to redirect mc
's man page to a text file using man mc > mc
, but I accidentally executed man mc > mc grep
. What resulted was a text file named mc
containing two concatenated mc
man pages.
I then tried man ls > 1 abc
, which resulted in text file named 1
containing the ls
man page and an error message in the terminal: No manual entry for abc
.
Next I tried man du > du ls tac
. I expected three concatenated du
man pages, but what actually resulted was a text file named du
containing the man pages of du
, ls
and tac
concatenated.
Why did each command produced the results it did?
io-redirection man
In the first case, what was the resulting text file’s name? (Presumablymc
...)
– Stephen Kitt
Dec 23 '18 at 16:07
@Stephen Kitt: Yes,mc
.
– EmmaV
Dec 23 '18 at 16:11
I can't reproduce the first finding - I getmc
andgrep
inmc
, which is to be expected.
– tink
Dec 23 '18 at 16:41
I would expectmc
andgrep
man pages in a file calledmc
for first example.
– ctrl-alt-delor
Dec 23 '18 at 16:45
Hi EmmaV, I wondered if you would consider accepting my Answer? If you think it could use improvement in some way, please let me know how.
– cryptarch
yesterday
add a comment |
I wanted to redirect mc
's man page to a text file using man mc > mc
, but I accidentally executed man mc > mc grep
. What resulted was a text file named mc
containing two concatenated mc
man pages.
I then tried man ls > 1 abc
, which resulted in text file named 1
containing the ls
man page and an error message in the terminal: No manual entry for abc
.
Next I tried man du > du ls tac
. I expected three concatenated du
man pages, but what actually resulted was a text file named du
containing the man pages of du
, ls
and tac
concatenated.
Why did each command produced the results it did?
io-redirection man
I wanted to redirect mc
's man page to a text file using man mc > mc
, but I accidentally executed man mc > mc grep
. What resulted was a text file named mc
containing two concatenated mc
man pages.
I then tried man ls > 1 abc
, which resulted in text file named 1
containing the ls
man page and an error message in the terminal: No manual entry for abc
.
Next I tried man du > du ls tac
. I expected three concatenated du
man pages, but what actually resulted was a text file named du
containing the man pages of du
, ls
and tac
concatenated.
Why did each command produced the results it did?
io-redirection man
io-redirection man
edited Dec 23 '18 at 16:37
Jeff Schaller
39k1053125
39k1053125
asked Dec 23 '18 at 16:01
EmmaV
1,1091331
1,1091331
In the first case, what was the resulting text file’s name? (Presumablymc
...)
– Stephen Kitt
Dec 23 '18 at 16:07
@Stephen Kitt: Yes,mc
.
– EmmaV
Dec 23 '18 at 16:11
I can't reproduce the first finding - I getmc
andgrep
inmc
, which is to be expected.
– tink
Dec 23 '18 at 16:41
I would expectmc
andgrep
man pages in a file calledmc
for first example.
– ctrl-alt-delor
Dec 23 '18 at 16:45
Hi EmmaV, I wondered if you would consider accepting my Answer? If you think it could use improvement in some way, please let me know how.
– cryptarch
yesterday
add a comment |
In the first case, what was the resulting text file’s name? (Presumablymc
...)
– Stephen Kitt
Dec 23 '18 at 16:07
@Stephen Kitt: Yes,mc
.
– EmmaV
Dec 23 '18 at 16:11
I can't reproduce the first finding - I getmc
andgrep
inmc
, which is to be expected.
– tink
Dec 23 '18 at 16:41
I would expectmc
andgrep
man pages in a file calledmc
for first example.
– ctrl-alt-delor
Dec 23 '18 at 16:45
Hi EmmaV, I wondered if you would consider accepting my Answer? If you think it could use improvement in some way, please let me know how.
– cryptarch
yesterday
In the first case, what was the resulting text file’s name? (Presumably
mc
...)– Stephen Kitt
Dec 23 '18 at 16:07
In the first case, what was the resulting text file’s name? (Presumably
mc
...)– Stephen Kitt
Dec 23 '18 at 16:07
@Stephen Kitt: Yes,
mc
.– EmmaV
Dec 23 '18 at 16:11
@Stephen Kitt: Yes,
mc
.– EmmaV
Dec 23 '18 at 16:11
I can't reproduce the first finding - I get
mc
and grep
in mc
, which is to be expected.– tink
Dec 23 '18 at 16:41
I can't reproduce the first finding - I get
mc
and grep
in mc
, which is to be expected.– tink
Dec 23 '18 at 16:41
I would expect
mc
and grep
man pages in a file called mc
for first example.– ctrl-alt-delor
Dec 23 '18 at 16:45
I would expect
mc
and grep
man pages in a file called mc
for first example.– ctrl-alt-delor
Dec 23 '18 at 16:45
Hi EmmaV, I wondered if you would consider accepting my Answer? If you think it could use improvement in some way, please let me know how.
– cryptarch
yesterday
Hi EmmaV, I wondered if you would consider accepting my Answer? If you think it could use improvement in some way, please let me know how.
– cryptarch
yesterday
add a comment |
2 Answers
2
active
oldest
votes
This is consistent with a relatively obscure part of the Bash manual, which states under the section Shell Grammar:
A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator. The
first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command.
(Emphasis mine.)
What that means is that you can "mix" any redirections in with the command and its arguments.
For example, echo > world hello
is equivalent to echo hello > world
.
In other words, when you run a command like man du > du ls tac
, it is equivalent to running:
man du ls tac > du
That these three manpages all end up concatenated into a file named du
is then the result of how man
behaves when its output is being redirected or piped: it will no longer try to use a pager and will essentially act like cat
.
add a comment |
Only for reference/curiosity:
I know I'm not answering your question but in case you need to redirect the content of a man page you can do it with col(1)
man 1 col | col -b -x > manfile.foo
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f490621%2fstrange-behaviour-redirecting-man-pages%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is consistent with a relatively obscure part of the Bash manual, which states under the section Shell Grammar:
A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator. The
first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command.
(Emphasis mine.)
What that means is that you can "mix" any redirections in with the command and its arguments.
For example, echo > world hello
is equivalent to echo hello > world
.
In other words, when you run a command like man du > du ls tac
, it is equivalent to running:
man du ls tac > du
That these three manpages all end up concatenated into a file named du
is then the result of how man
behaves when its output is being redirected or piped: it will no longer try to use a pager and will essentially act like cat
.
add a comment |
This is consistent with a relatively obscure part of the Bash manual, which states under the section Shell Grammar:
A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator. The
first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command.
(Emphasis mine.)
What that means is that you can "mix" any redirections in with the command and its arguments.
For example, echo > world hello
is equivalent to echo hello > world
.
In other words, when you run a command like man du > du ls tac
, it is equivalent to running:
man du ls tac > du
That these three manpages all end up concatenated into a file named du
is then the result of how man
behaves when its output is being redirected or piped: it will no longer try to use a pager and will essentially act like cat
.
add a comment |
This is consistent with a relatively obscure part of the Bash manual, which states under the section Shell Grammar:
A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator. The
first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command.
(Emphasis mine.)
What that means is that you can "mix" any redirections in with the command and its arguments.
For example, echo > world hello
is equivalent to echo hello > world
.
In other words, when you run a command like man du > du ls tac
, it is equivalent to running:
man du ls tac > du
That these three manpages all end up concatenated into a file named du
is then the result of how man
behaves when its output is being redirected or piped: it will no longer try to use a pager and will essentially act like cat
.
This is consistent with a relatively obscure part of the Bash manual, which states under the section Shell Grammar:
A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator. The
first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command.
(Emphasis mine.)
What that means is that you can "mix" any redirections in with the command and its arguments.
For example, echo > world hello
is equivalent to echo hello > world
.
In other words, when you run a command like man du > du ls tac
, it is equivalent to running:
man du ls tac > du
That these three manpages all end up concatenated into a file named du
is then the result of how man
behaves when its output is being redirected or piped: it will no longer try to use a pager and will essentially act like cat
.
answered Dec 23 '18 at 16:38
cryptarch
5116
5116
add a comment |
add a comment |
Only for reference/curiosity:
I know I'm not answering your question but in case you need to redirect the content of a man page you can do it with col(1)
man 1 col | col -b -x > manfile.foo
add a comment |
Only for reference/curiosity:
I know I'm not answering your question but in case you need to redirect the content of a man page you can do it with col(1)
man 1 col | col -b -x > manfile.foo
add a comment |
Only for reference/curiosity:
I know I'm not answering your question but in case you need to redirect the content of a man page you can do it with col(1)
man 1 col | col -b -x > manfile.foo
Only for reference/curiosity:
I know I'm not answering your question but in case you need to redirect the content of a man page you can do it with col(1)
man 1 col | col -b -x > manfile.foo
answered Dec 24 '18 at 12:20
tntx
392
392
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%2f490621%2fstrange-behaviour-redirecting-man-pages%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
In the first case, what was the resulting text file’s name? (Presumably
mc
...)– Stephen Kitt
Dec 23 '18 at 16:07
@Stephen Kitt: Yes,
mc
.– EmmaV
Dec 23 '18 at 16:11
I can't reproduce the first finding - I get
mc
andgrep
inmc
, which is to be expected.– tink
Dec 23 '18 at 16:41
I would expect
mc
andgrep
man pages in a file calledmc
for first example.– ctrl-alt-delor
Dec 23 '18 at 16:45
Hi EmmaV, I wondered if you would consider accepting my Answer? If you think it could use improvement in some way, please let me know how.
– cryptarch
yesterday