Why is it that we can redirect the input of 'less' command, but we can't run less without any arguments? Why is it that we can redirect the input of 'less' command, but we can't run less without any arguments? unix unix

Why is it that we can redirect the input of 'less' command, but we can't run less without any arguments?


The less accepts input from stdin or from a file.

Since it doesn't make sense to accept input from a terminal (just to display the same input back to a terminal), the less program probably checks if stdin is a terminal (with isatty) and refuses to run.

See man 3 isatty


Less is a pager, a UNIX term for a program that shows output one screenful at a time. If you pipe a program's output to less, it shows the output one page a time. If you pass file names on the command line, it shows those files page by page.

If you do neither, there's nothing to page through. It throws an error because there's nothing sensible it can do. What do you want it to show?