2

I just did man [ and it opened the manual.

Then I tried doing man > but I get this error:

-bash: syntax error near unexpected token `newline'

How is > different from [?

Honey
  • 124
  • 9
  • 3
    Altough `[` or `test` is a builtin it also exists as a separate command (`/bin/[`). `>` is a redirection operator and is part of a shell implementation (does not exist as a separate command). Info about redirection operators can be consulted from the shell man page (e.g, bash, zsh, ksh, etc.). – Paulo Tomé Mar 30 '20 at 18:08
  • I see. so how do I pull up documentation on `>` from with my terminal/command line? – Honey Mar 30 '20 at 18:09
  • so `>` is built in to `bash` or whatever shell I'm using. `[` is built into what? – Honey Mar 30 '20 at 18:12
  • 2
    Please see [What is the difference between a builtin command and one that is not?](https://unix.stackexchange.com/questions/11454/what-is-the-difference-between-a-builtin-command-and-one-that-is-not). – Paulo Tomé Mar 30 '20 at 18:19
  • 1
    `[` (or its alias `test`) has two implementations; it exists as a shell builtin and as a separate command. Whereas the redirection operators only exist as a builtin command. – Paulo Tomé Mar 30 '20 at 18:22
  • 1
    Shell builtins do not have their own individual man pages l. They're documented in the respective shell man page. – Paulo Tomé Mar 30 '20 at 18:32

1 Answers1

1

As you have seen, the command man > will invoke redirection rather than give you a man page for it.

Since > is a shell operator, you need to go to the man page for your shell, for example if you run bash you can use man bash and look for the section on 'REDIRECTION'. All the shell redirection operators will be listed there; they don't have their own man pages.

ilkkachu
  • 133,243
  • 15
  • 236
  • 397
user1794469
  • 3,909
  • 1
  • 23
  • 42
  • I hit `cmmd + f` and searched for `REDIRECTION` but wasn't able to find it. The search only worked if `REDIRECTION` was visible. Is that also happening for you? Is that expected or that's a bug? – Honey Mar 30 '20 at 19:07
  • My `MANPAGER` is `less` so I use forward slash `/` which will accept regex. For many distros this is the default `MANPAGER` but you can change it if you like. – user1794469 Mar 30 '20 at 19:58